Skip to content

Commit 57f7d83

Browse files
committed
[folding] add setting to allow clicking in empty space to unfold. Fixes microsoft#88522
1 parent 9db2563 commit 57f7d83

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

src/vs/editor/common/config/editorOptions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export interface IEditorOptions {
510510
* Controls whether clicking on the empty content after a folded line will unfold the line.
511511
* Defaults to false.
512512
*/
513-
unfoldOnClickInEmptyContent?: boolean;
513+
unfoldOnClickAfterEndOfLine?: boolean;
514514
/**
515515
* Enable highlighting of matching brackets.
516516
* Defaults to 'always'.
@@ -3325,7 +3325,7 @@ export const enum EditorOption {
33253325
folding,
33263326
foldingStrategy,
33273327
foldingHighlight,
3328-
unfoldOnClickInEmptyContent,
3328+
unfoldOnClickAfterEndOfLine,
33293329
fontFamily,
33303330
fontInfo,
33313331
fontLigatures,
@@ -3625,9 +3625,9 @@ export const EditorOptions = {
36253625
EditorOption.foldingHighlight, 'foldingHighlight', true,
36263626
{ description: nls.localize('foldingHighlight', "Controls whether the editor should highlight folded ranges.") }
36273627
)),
3628-
unfoldOnClickInEmptyContent: register(new EditorBooleanOption(
3629-
EditorOption.unfoldOnClickInEmptyContent, 'unfoldOnClickInEmptyContent', false,
3630-
{ description: nls.localize('unfoldOnClickInEmptyContent', "Controls whether clicking on the empty content after a folded line will unfold the line.") }
3628+
unfoldOnClickAfterEndOfLine: register(new EditorBooleanOption(
3629+
EditorOption.unfoldOnClickAfterEndOfLine, 'unfoldOnClickAfterEndOfLine', false,
3630+
{ description: nls.localize('unfoldOnClickAfterEndOfLine', "Controls whether clicking on the empty content after a folded line will unfold the line.") }
36313631
)),
36323632
fontFamily: register(new EditorStringOption(
36333633
EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,

src/vs/editor/common/standalone/standaloneEnums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export enum EditorOption {
199199
folding = 31,
200200
foldingStrategy = 32,
201201
foldingHighlight = 33,
202-
unfoldOnClickInEmptyContent = 34,
202+
unfoldOnClickAfterEndOfLine = 34,
203203
fontFamily = 35,
204204
fontInfo = 36,
205205
fontLigatures = 37,

src/vs/editor/contrib/folding/folding.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class FoldingController extends Disposable implements IEditorContribution
6262
private readonly editor: ICodeEditor;
6363
private _isEnabled: boolean;
6464
private _useFoldingProviders: boolean;
65-
private _unfoldOnClickInEmptyContent: boolean;
65+
private _unfoldOnClickAfterEndOfLine: boolean;
6666

6767
private readonly foldingDecorationProvider: FoldingDecorationProvider;
6868

@@ -92,7 +92,7 @@ export class FoldingController extends Disposable implements IEditorContribution
9292
const options = this.editor.getOptions();
9393
this._isEnabled = options.get(EditorOption.folding);
9494
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
95-
this._unfoldOnClickInEmptyContent = options.get(EditorOption.unfoldOnClickInEmptyContent);
95+
this._unfoldOnClickAfterEndOfLine = options.get(EditorOption.unfoldOnClickAfterEndOfLine);
9696

9797
this.foldingModel = null;
9898
this.hiddenRangeModel = null;
@@ -114,8 +114,7 @@ export class FoldingController extends Disposable implements IEditorContribution
114114

115115
this._register(this.editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
116116
if (e.hasChanged(EditorOption.folding)) {
117-
const options = this.editor.getOptions();
118-
this._isEnabled = options.get(EditorOption.folding);
117+
this._isEnabled = this.editor.getOptions().get(EditorOption.folding);
119118
this.foldingEnabled.set(this._isEnabled);
120119
this.onModelChanged();
121120
}
@@ -126,12 +125,11 @@ export class FoldingController extends Disposable implements IEditorContribution
126125
this.onModelContentChanged();
127126
}
128127
if (e.hasChanged(EditorOption.foldingStrategy)) {
129-
const options = this.editor.getOptions();
130-
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
128+
this._useFoldingProviders = this.editor.getOptions().get(EditorOption.foldingStrategy) !== 'indentation';
131129
this.onFoldingStrategyChanged();
132130
}
133-
if (e.hasChanged(EditorOption.unfoldOnClickInEmptyContent)) {
134-
this._unfoldOnClickInEmptyContent = options.get(EditorOption.unfoldOnClickInEmptyContent);
131+
if (e.hasChanged(EditorOption.unfoldOnClickAfterEndOfLine)) {
132+
this._unfoldOnClickAfterEndOfLine = this.editor.getOptions().get(EditorOption.unfoldOnClickAfterEndOfLine);
135133
}
136134
}));
137135
this.onModelChanged();
@@ -370,7 +368,7 @@ export class FoldingController extends Disposable implements IEditorContribution
370368
iconClicked = true;
371369
break;
372370
case MouseTargetType.CONTENT_EMPTY: {
373-
if (this._unfoldOnClickInEmptyContent && this.hiddenRangeModel.hasRanges()) {
371+
if (this._unfoldOnClickAfterEndOfLine && this.hiddenRangeModel.hasRanges()) {
374372
const data = e.target.detail as IEmptyContentData;
375373
if (!data.isAfterLines) {
376374
break;

src/vs/monaco.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,7 +3035,7 @@ declare namespace monaco.editor {
30353035
* Controls whether clicking on the empty content after a folded line will unfold the line.
30363036
* Defaults to false.
30373037
*/
3038-
unfoldOnClickInEmptyContent?: boolean;
3038+
unfoldOnClickAfterEndOfLine?: boolean;
30393039
/**
30403040
* Enable highlighting of matching brackets.
30413041
* Defaults to 'always'.
@@ -3825,7 +3825,7 @@ declare namespace monaco.editor {
38253825
folding = 31,
38263826
foldingStrategy = 32,
38273827
foldingHighlight = 33,
3828-
unfoldOnClickInEmptyContent = 34,
3828+
unfoldOnClickAfterEndOfLine = 34,
38293829
fontFamily = 35,
38303830
fontInfo = 36,
38313831
fontLigatures = 37,
@@ -3941,7 +3941,7 @@ declare namespace monaco.editor {
39413941
folding: IEditorOption<EditorOption.folding, boolean>;
39423942
foldingStrategy: IEditorOption<EditorOption.foldingStrategy, 'auto' | 'indentation'>;
39433943
foldingHighlight: IEditorOption<EditorOption.foldingHighlight, boolean>;
3944-
unfoldOnClickInEmptyContent: IEditorOption<EditorOption.unfoldOnClickInEmptyContent, boolean>;
3944+
unfoldOnClickAfterEndOfLine: IEditorOption<EditorOption.unfoldOnClickAfterEndOfLine, boolean>;
39453945
fontFamily: IEditorOption<EditorOption.fontFamily, string>;
39463946
fontInfo: IEditorOption<EditorOption.fontInfo, FontInfo>;
39473947
fontLigatures2: IEditorOption<EditorOption.fontLigatures, string>;

0 commit comments

Comments
 (0)