Skip to content

Commit 7892603

Browse files
glennsartiTylerLeonhardt
authored andcommitted
(GH-1458) Remove region folding from non-region areas (#1467)
Previously all of the folding ranges were either Region or Comment, however this is confusing e.g. a Here String is neither a region or a comment. The VS Code API does state that the range kind property is optional. This commit changes the range kind for braces, parentheses and here strings to be null, that is, neither a region or comment range. This makes editor commands like 'Fold All Regions' behave as a user expects.
1 parent d3ce263 commit 7892603

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/features/Folding.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -446,29 +446,29 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
446446
tokens,
447447
"punctuation.section.braces.begin.powershell",
448448
"punctuation.section.braces.end.powershell",
449-
vscode.FoldingRangeKind.Region, document)
449+
null, document)
450450
.forEach((match) => { matchedTokens.push(match); });
451451

452452
// Find matching parentheses ( -> )
453453
this.matchScopeElements(
454454
tokens,
455455
"punctuation.section.group.begin.powershell",
456456
"punctuation.section.group.end.powershell",
457-
vscode.FoldingRangeKind.Region, document)
457+
null, document)
458458
.forEach((match) => { matchedTokens.push(match); });
459459

460460
// Find contiguous here strings @' -> '@
461461
this.matchContiguousScopeElements(
462462
tokens,
463463
"string.quoted.single.heredoc.powershell",
464-
vscode.FoldingRangeKind.Region, document)
464+
null, document)
465465
.forEach((match) => { matchedTokens.push(match); });
466466

467467
// Find contiguous here strings @" -> "@
468468
this.matchContiguousScopeElements(
469469
tokens,
470470
"string.quoted.double.heredoc.powershell",
471-
vscode.FoldingRangeKind.Region, document)
471+
null, document)
472472
.forEach((match) => { matchedTokens.push(match); });
473473

474474
// Find matching comment regions #region -> #endregion

test/features/folding.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ suite("Features", () => {
4141
{ start: 0, end: 4, kind: 3 },
4242
{ start: 1, end: 3, kind: 1 },
4343
{ start: 10, end: 15, kind: 1 },
44-
{ start: 16, end: 60, kind: 3 },
44+
{ start: 16, end: 60, kind: null },
4545
{ start: 17, end: 22, kind: 1 },
46-
{ start: 23, end: 26, kind: 3 },
47-
{ start: 28, end: 31, kind: 3 },
46+
{ start: 23, end: 26, kind: null },
47+
{ start: 28, end: 31, kind: null },
4848
{ start: 35, end: 37, kind: 1 },
4949
{ start: 39, end: 49, kind: 3 },
5050
{ start: 41, end: 45, kind: 3 },
51-
{ start: 51, end: 53, kind: 3 },
52-
{ start: 56, end: 59, kind: 3 },
51+
{ start: 51, end: 53, kind: null },
52+
{ start: 56, end: 59, kind: null },
5353
{ start: 64, end: 66, kind: 1 },
5454
{ start: 67, end: 72, kind: 3 },
5555
{ start: 68, end: 70, kind: 1 },

0 commit comments

Comments
 (0)