Skip to content

[json] add #region folding markers to language configuration#318515

Open
yogeshwaran-c wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/jsonc-region-folding-markers
Open

[json] add #region folding markers to language configuration#318515
yogeshwaran-c wants to merge 1 commit into
microsoft:mainfrom
yogeshwaran-c:fix/jsonc-region-folding-markers

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

Minimap section headers (editor.minimap.showRegionSectionHeaders) are missing for //#region / //#endregion comments in jsonc files, even though vscode-json-languageservice already exposes folding ranges for those comments.

The reason is that minimap section headers are sourced from the language configuration's folding.markers, not from LSP folding ranges, and the json/jsonc language configuration does not declare folding markers.

Repro (in a .jsonc file, with editor.minimap.showRegionSectionHeaders enabled):

{
    "editor.showFoldingControls": "always",

    // MARK: Foo
    //#region Bar

    "editor.minimap.showRegionSectionHeaders": true

    //#endregion
}

Before this change: only the MARK: Foo header appears in the minimap.
After this change: both MARK: Foo and the Bar region label appear.

Fixes #219561

What is the new behavior?

Adds a folding.markers section to extensions/json/language-configuration.json matching the same patterns already used by vscode-json-languageservice for jsonc folding, and matching the convention used by typescript-basics, javascript, and other built-in language configurations:

"folding": {
    "markers": {
        "start": "^\s*//\s*#?region\b",
        "end": "^\s*//\s*#?endregion\b"
    }
}

The configuration is shared across json, jsonc, jsonl, and snippets. In practice these markers only match inside line comments (//...), which are syntactically valid only in jsonc and snippets; valid json/jsonl content cannot contain // outside of strings, so the markers are inert there. This matches the existing shared treatment of lineComment: "//" already declared in the same file.

How to test

  1. Open Insiders with this change applied.
  2. Create a .jsonc file with //#region NAME / //#endregion blocks.
  3. Enable editor.minimap.showRegionSectionHeaders and confirm the region name appears in the minimap.
  4. Confirm folding by the editor (Ctrl+Shift+[) still collapses the region as before.

Adds folding markers for //#region and //#endregion to the json/jsonc
language configuration so that the minimap section headers feature
(editor.minimap.showRegionSectionHeaders) recognizes them and renders
the corresponding section labels.

vscode-json-languageservice already provides folding ranges for these
markers in jsonc, but the minimap section headers contribution reads
folding markers from the language configuration only, which is why the
labels were missing.

Fixes microsoft#219561
Copilot AI review requested due to automatic review settings May 27, 2026 06:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds region folding support to the JSON language configuration so // #region / // #endregion markers can be used for code folding.

Changes:

  • Add folding marker configuration for // #region / // #endregion in JSON language configuration.

Comment on lines +69 to +74
"folding": {
"markers": {
"start": "^\\s*//\\s*#?region\\b",
"end": "^\\s*//\\s*#?endregion\\b"
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimap section headers missing forjsonc #region

3 participants