From faf5f7054790e0c49fd117463640584286c15ad1 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Mon, 6 Aug 2018 09:28:12 +0800 Subject: [PATCH] (GH-1458) Remove region folding from non-region areas 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. --- src/features/Folding.ts | 8 ++++---- test/features/folding.test.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/features/Folding.ts b/src/features/Folding.ts index c8f7e621a7..1a68b8c741 100644 --- a/src/features/Folding.ts +++ b/src/features/Folding.ts @@ -446,7 +446,7 @@ 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 ( -> ) @@ -454,21 +454,21 @@ export class FoldingProvider implements vscode.FoldingRangeProvider { 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 diff --git a/test/features/folding.test.ts b/test/features/folding.test.ts index e4744a9329..583abfb85d 100644 --- a/test/features/folding.test.ts +++ b/test/features/folding.test.ts @@ -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 },