Skip to content

Commit

Permalink
(GH-1458) Remove region folding from non-region areas (#1467)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glennsarti authored and TylerLeonhardt committed Aug 6, 2018
1 parent d3ce263 commit 7892603
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/features/Folding.ts
Expand Up @@ -446,29 +446,29 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
tokens,
"punctuation.section.braces.begin.powershell",
"punctuation.section.braces.end.powershell",
vscode.FoldingRangeKind.Region, document)
null, document)
.forEach((match) => { matchedTokens.push(match); });

// Find matching parentheses ( -> )
this.matchScopeElements(
tokens,
"punctuation.section.group.begin.powershell",
"punctuation.section.group.end.powershell",
vscode.FoldingRangeKind.Region, document)
null, document)
.forEach((match) => { matchedTokens.push(match); });

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

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

// Find matching comment regions #region -> #endregion
Expand Down
10 changes: 5 additions & 5 deletions test/features/folding.test.ts
Expand Up @@ -41,15 +41,15 @@ suite("Features", () => {
{ start: 0, end: 4, kind: 3 },
{ start: 1, end: 3, kind: 1 },
{ start: 10, end: 15, kind: 1 },
{ start: 16, end: 60, kind: 3 },
{ start: 16, end: 60, kind: null },
{ start: 17, end: 22, kind: 1 },
{ start: 23, end: 26, kind: 3 },
{ start: 28, end: 31, kind: 3 },
{ start: 23, end: 26, kind: null },
{ start: 28, end: 31, kind: null },
{ start: 35, end: 37, kind: 1 },
{ start: 39, end: 49, kind: 3 },
{ start: 41, end: 45, kind: 3 },
{ start: 51, end: 53, kind: 3 },
{ start: 56, end: 59, kind: 3 },
{ start: 51, end: 53, kind: null },
{ start: 56, end: 59, kind: null },
{ start: 64, end: 66, kind: 1 },
{ start: 67, end: 72, kind: 3 },
{ start: 68, end: 70, kind: 1 },
Expand Down

0 comments on commit 7892603

Please sign in to comment.