[json] add #region folding markers to language configuration#318515
Open
yogeshwaran-c wants to merge 1 commit into
Open
[json] add #region folding markers to language configuration#318515yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
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
Contributor
There was a problem hiding this comment.
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/// #endregionin JSON language configuration.
Comment on lines
+69
to
+74
| "folding": { | ||
| "markers": { | ||
| "start": "^\\s*//\\s*#?region\\b", | ||
| "end": "^\\s*//\\s*#?endregion\\b" | ||
| } | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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///#endregioncomments injsoncfiles, even thoughvscode-json-languageservicealready 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
.jsoncfile, witheditor.minimap.showRegionSectionHeadersenabled):{ "editor.showFoldingControls": "always", // MARK: Foo //#region Bar "editor.minimap.showRegionSectionHeaders": true //#endregion }Before this change: only the
MARK: Fooheader appears in the minimap.After this change: both
MARK: Fooand theBarregion label appear.Fixes #219561
What is the new behavior?
Adds a
folding.markerssection toextensions/json/language-configuration.jsonmatching the same patterns already used byvscode-json-languageservicefor jsonc folding, and matching the convention used bytypescript-basics,javascript, and other built-in language configurations:The configuration is shared across
json,jsonc,jsonl, andsnippets. In practice these markers only match inside line comments (//...), which are syntactically valid only injsoncandsnippets; validjson/jsonlcontent cannot contain//outside of strings, so the markers are inert there. This matches the existing shared treatment oflineComment: "//"already declared in the same file.How to test
.jsoncfile with//#region NAME///#endregionblocks.editor.minimap.showRegionSectionHeadersand confirm the region name appears in the minimap.