Skip to content

Commit ef63eea

Browse files
glennsartiTylerLeonhardt
authored andcommitted
(GH-1336) Add syntax aware folding provider (#1355)
* (GH-1336) Add syntax aware folding provider Previously the Powershell extension used the default VSCode indentation based folding regions. This commit adds the skeleton for a syntax aware, client-side folding provider as per the API introduced in VSCode 1.23.0 * The client side detection uses the PowerShell Textmate grammar file and the vscode-text node module to parse the text file into tokens which will be matched in later commits. * However due to the way vscode imports the vscode-textmate module we can't simply just import it, instead we need to use file based require statements microsoft/vscode#46281 * This also means it's difficult to use any typings exposed in that module. As we only need one interface, this is replicated verbatim in the file, but not exported * Logging is added to help diagnose potential issues * (GH-1336) Add syntax folding for braces and parentheses This commit adds detection of text regions bounded by braces { } and parentheses ( ). This provides syntax aware folding for functions, arrays and hash tables. * (GH-1336) Add syntax folding for here strings This commit adds detection of text regions composed of single and double quoted here strings; @' '@ and @" "@. * (GH-1336) Add syntax folding for comments This commit adds syntax aware folding for comment regions * Contiguous blocks of line comments `# ....` * Block comments `<# ... #>` * Region bound comments `# region ... # endregion` * (GH-1336) Add integration tests for the Folding Provider Previously there were no tests to verify the folding provider. Due to the provider depending on 3rd party libraries (vscode-textmate and PowerShell grammar file) these tests will provide a degree of detection if breaking changes occur. * (maint) Modify tslint configuration for test files Previously tslint was raising errors in Travis CI saying that the excluded test fixtures directory was not included in the project. This was by design however it appears to be a known bug palantir/tslint#3793. This commit removes the exclude for test files from linting and adds a tslint directive in the default index.ts file. A tslint directive is used instead of solving the issue because this is the default testing file for VS Code extesions and shouldn't really be modified unless absolutely necessary. In this instance it was safer for a tslint directive. * (GH-1336) Add Code Folding settings and enable by default Previously the syntax folding was available for all users. However it was able to be configured or turned off. This commit adds a new `codeFolding` settings section, with the syntax folding feature enabled by default. * add copyright headers
1 parent f54a611 commit ef63eea

File tree

8 files changed

+758
-2
lines changed

8 files changed

+758
-2
lines changed

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"publisher": "ms-vscode",
66
"description": "Develop PowerShell scripts in Visual Studio Code!",
77
"engines": {
8-
"vscode": "^1.22.0"
8+
"vscode": "^1.23.0"
99
},
1010
"license": "SEE LICENSE IN LICENSE.txt",
1111
"homepage": "https://github.com/PowerShell/vscode-powershell/blob/master/README.md",
@@ -52,7 +52,7 @@
5252
"vscode.powershell"
5353
],
5454
"scripts": {
55-
"compile": "tsc -v && tsc -p ./ && tslint -p ./ -e test/*",
55+
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
5656
"compile-watch": "tsc -watch -p ./",
5757
"postinstall": "node ./node_modules/vscode/bin/install",
5858
"test": "node ./node_modules/vscode/bin/test"
@@ -467,6 +467,11 @@
467467
"default": "",
468468
"description": "Specifies the path to a PowerShell Script Analyzer settings file. To override the default settings for all projects, enter an absolute path, or enter a path relative to your workspace."
469469
},
470+
"powershell.codeFolding.enable": {
471+
"type": "boolean",
472+
"default": true,
473+
"description": "Enables syntax based code folding. When disabled, the default indentation based code folding is used."
474+
},
470475
"powershell.codeFormatting.preset": {
471476
"type": "string",
472477
"enum": [

0 commit comments

Comments
 (0)