diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d46c26f7..b6f89e3338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # vscode-powershell Release History +- [vscode-PowerShell #????](https://github.com/PowerShell/vscode-PowerShell/pull/????) - + New code folding option - 'powershell.codeFolding.showLastLine' - Set true to show the last line of a folded section similar to the default VSCode folding style + ## v1.8.4 ### Friday, August 31, 2018 #### [vscode-powershell](https://github.com/powershell/vscode-powershell) diff --git a/package.json b/package.json index 61f20bacb0..535e77b9a5 100644 --- a/package.json +++ b/package.json @@ -478,6 +478,11 @@ "default": true, "description": "Enables syntax based code folding. When disabled, the default indentation based code folding is used." }, + "powershell.codeFolding.showLastLine": { + "type": "boolean", + "default": false, + "description": "Shows the last line of a folded section similar to the default VSCode folding style. When disabled, the entire folded region is hidden." + }, "powershell.codeFormatting.preset": { "type": "string", "enum": [ diff --git a/src/features/Folding.ts b/src/features/Folding.ts index 1e68f3b33b..05e79298e3 100644 --- a/src/features/Folding.ts +++ b/src/features/Folding.ts @@ -101,10 +101,13 @@ class LineNumberRange { */ public rangeKind: vscode.FoldingRangeKind; + private settings: Settings.ISettings; + constructor( rangeKind: vscode.FoldingRangeKind, ) { this.rangeKind = rangeKind; + this.settings = Settings.load(); } /** @@ -121,6 +124,9 @@ class LineNumberRange { ): LineNumberRange { this.startline = document.positionAt(start.startIndex).line; this.endline = document.positionAt(end.startIndex).line; + if (this.settings.codeFolding && this.settings.codeFolding.showLastLine) { + this.endline--; + } return this; } diff --git a/src/settings.ts b/src/settings.ts index 42fe34f803..c7a87ffef7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -31,6 +31,7 @@ export interface IBugReportingSettings { export interface ICodeFoldingSettings { enable?: boolean; + showLastLine?: boolean; } export interface ICodeFormattingSettings { @@ -116,6 +117,7 @@ export function load(): ISettings { const defaultCodeFoldingSettings: ICodeFoldingSettings = { enable: true, + showLastLine: false, }; const defaultCodeFormattingSettings: ICodeFormattingSettings = {