Skip to content

Commit 03b30ff

Browse files
committed
[folding] add setting to allow clicking in empty space to unfold. Fixes microsoft#88522
1 parent b893a20 commit 03b30ff

4 files changed

Lines changed: 191 additions & 159 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ export interface IEditorOptions {
506506
* Defaults to 'mouseover'.
507507
*/
508508
showFoldingControls?: 'always' | 'mouseover';
509+
/**
510+
* Controls whether clicking on the empty content after a folded line will unfold the line.
511+
* Defaults to false.
512+
*/
513+
unfoldOnClickInEmptyContent?: boolean;
509514
/**
510515
* Enable highlighting of matching brackets.
511516
* Defaults to 'always'.
@@ -3320,6 +3325,7 @@ export const enum EditorOption {
33203325
folding,
33213326
foldingStrategy,
33223327
foldingHighlight,
3328+
unfoldOnClickInEmptyContent,
33233329
fontFamily,
33243330
fontInfo,
33253331
fontLigatures,
@@ -3619,6 +3625,10 @@ export const EditorOptions = {
36193625
EditorOption.foldingHighlight, 'foldingHighlight', true,
36203626
{ description: nls.localize('foldingHighlight', "Controls whether the editor should highlight folded ranges.") }
36213627
)),
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.") }
3631+
)),
36223632
fontFamily: register(new EditorStringOption(
36233633
EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
36243634
{ description: nls.localize('fontFamily', "Controls the font family.") }

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

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -199,85 +199,86 @@ export enum EditorOption {
199199
folding = 31,
200200
foldingStrategy = 32,
201201
foldingHighlight = 33,
202-
fontFamily = 34,
203-
fontInfo = 35,
204-
fontLigatures = 36,
205-
fontSize = 37,
206-
fontWeight = 38,
207-
formatOnPaste = 39,
208-
formatOnType = 40,
209-
glyphMargin = 41,
210-
gotoLocation = 42,
211-
hideCursorInOverviewRuler = 43,
212-
highlightActiveIndentGuide = 44,
213-
hover = 45,
214-
inDiffEditor = 46,
215-
letterSpacing = 47,
216-
lightbulb = 48,
217-
lineDecorationsWidth = 49,
218-
lineHeight = 50,
219-
lineNumbers = 51,
220-
lineNumbersMinChars = 52,
221-
links = 53,
222-
matchBrackets = 54,
223-
minimap = 55,
224-
mouseStyle = 56,
225-
mouseWheelScrollSensitivity = 57,
226-
mouseWheelZoom = 58,
227-
multiCursorMergeOverlapping = 59,
228-
multiCursorModifier = 60,
229-
multiCursorPaste = 61,
230-
occurrencesHighlight = 62,
231-
overviewRulerBorder = 63,
232-
overviewRulerLanes = 64,
233-
padding = 65,
234-
parameterHints = 66,
235-
peekWidgetDefaultFocus = 67,
236-
definitionLinkOpensInPeek = 68,
237-
quickSuggestions = 69,
238-
quickSuggestionsDelay = 70,
239-
readOnly = 71,
240-
renderControlCharacters = 72,
241-
renderIndentGuides = 73,
242-
renderFinalNewline = 74,
243-
renderLineHighlight = 75,
244-
renderValidationDecorations = 76,
245-
renderWhitespace = 77,
246-
revealHorizontalRightPadding = 78,
247-
roundedSelection = 79,
248-
rulers = 80,
249-
scrollbar = 81,
250-
scrollBeyondLastColumn = 82,
251-
scrollBeyondLastLine = 83,
252-
scrollPredominantAxis = 84,
253-
selectionClipboard = 85,
254-
selectionHighlight = 86,
255-
selectOnLineNumbers = 87,
256-
showFoldingControls = 88,
257-
showUnused = 89,
258-
snippetSuggestions = 90,
259-
smoothScrolling = 91,
260-
stopRenderingLineAfter = 92,
261-
suggest = 93,
262-
suggestFontSize = 94,
263-
suggestLineHeight = 95,
264-
suggestOnTriggerCharacters = 96,
265-
suggestSelection = 97,
266-
tabCompletion = 98,
267-
useTabStops = 99,
268-
wordSeparators = 100,
269-
wordWrap = 101,
270-
wordWrapBreakAfterCharacters = 102,
271-
wordWrapBreakBeforeCharacters = 103,
272-
wordWrapColumn = 104,
273-
wordWrapMinified = 105,
274-
wrappingIndent = 106,
275-
wrappingStrategy = 107,
276-
editorClassName = 108,
277-
pixelRatio = 109,
278-
tabFocusMode = 110,
279-
layoutInfo = 111,
280-
wrappingInfo = 112
202+
unfoldOnClickInEmptyContent = 34,
203+
fontFamily = 35,
204+
fontInfo = 36,
205+
fontLigatures = 37,
206+
fontSize = 38,
207+
fontWeight = 39,
208+
formatOnPaste = 40,
209+
formatOnType = 41,
210+
glyphMargin = 42,
211+
gotoLocation = 43,
212+
hideCursorInOverviewRuler = 44,
213+
highlightActiveIndentGuide = 45,
214+
hover = 46,
215+
inDiffEditor = 47,
216+
letterSpacing = 48,
217+
lightbulb = 49,
218+
lineDecorationsWidth = 50,
219+
lineHeight = 51,
220+
lineNumbers = 52,
221+
lineNumbersMinChars = 53,
222+
links = 54,
223+
matchBrackets = 55,
224+
minimap = 56,
225+
mouseStyle = 57,
226+
mouseWheelScrollSensitivity = 58,
227+
mouseWheelZoom = 59,
228+
multiCursorMergeOverlapping = 60,
229+
multiCursorModifier = 61,
230+
multiCursorPaste = 62,
231+
occurrencesHighlight = 63,
232+
overviewRulerBorder = 64,
233+
overviewRulerLanes = 65,
234+
padding = 66,
235+
parameterHints = 67,
236+
peekWidgetDefaultFocus = 68,
237+
definitionLinkOpensInPeek = 69,
238+
quickSuggestions = 70,
239+
quickSuggestionsDelay = 71,
240+
readOnly = 72,
241+
renderControlCharacters = 73,
242+
renderIndentGuides = 74,
243+
renderFinalNewline = 75,
244+
renderLineHighlight = 76,
245+
renderValidationDecorations = 77,
246+
renderWhitespace = 78,
247+
revealHorizontalRightPadding = 79,
248+
roundedSelection = 80,
249+
rulers = 81,
250+
scrollbar = 82,
251+
scrollBeyondLastColumn = 83,
252+
scrollBeyondLastLine = 84,
253+
scrollPredominantAxis = 85,
254+
selectionClipboard = 86,
255+
selectionHighlight = 87,
256+
selectOnLineNumbers = 88,
257+
showFoldingControls = 89,
258+
showUnused = 90,
259+
snippetSuggestions = 91,
260+
smoothScrolling = 92,
261+
stopRenderingLineAfter = 93,
262+
suggest = 94,
263+
suggestFontSize = 95,
264+
suggestLineHeight = 96,
265+
suggestOnTriggerCharacters = 97,
266+
suggestSelection = 98,
267+
tabCompletion = 99,
268+
useTabStops = 100,
269+
wordSeparators = 101,
270+
wordWrap = 102,
271+
wordWrapBreakAfterCharacters = 103,
272+
wordWrapBreakBeforeCharacters = 104,
273+
wordWrapColumn = 105,
274+
wordWrapMinified = 106,
275+
wrappingIndent = 107,
276+
wrappingStrategy = 108,
277+
editorClassName = 109,
278+
pixelRatio = 110,
279+
tabFocusMode = 111,
280+
layoutInfo = 112,
281+
wrappingInfo = 113
281282
}
282283

283284
/**

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { FoldingDecorationProvider } from './foldingDecorations';
1919
import { FoldingRegions, FoldingRegion } from './foldingRanges';
2020
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
2121
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
22-
import { IMarginData } from 'vs/editor/browser/controller/mouseTarget';
22+
import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget';
2323
import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel';
2424
import { IRange } from 'vs/editor/common/core/range';
2525
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
@@ -62,6 +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;
6566

6667
private readonly foldingDecorationProvider: FoldingDecorationProvider;
6768

@@ -91,6 +92,7 @@ export class FoldingController extends Disposable implements IEditorContribution
9192
const options = this.editor.getOptions();
9293
this._isEnabled = options.get(EditorOption.folding);
9394
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
95+
this._unfoldOnClickInEmptyContent = options.get(EditorOption.unfoldOnClickInEmptyContent);
9496

9597
this.foldingModel = null;
9698
this.hiddenRangeModel = null;
@@ -128,6 +130,9 @@ export class FoldingController extends Disposable implements IEditorContribution
128130
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
129131
this.onFoldingStrategyChanged();
130132
}
133+
if (e.hasChanged(EditorOption.unfoldOnClickInEmptyContent)) {
134+
this._unfoldOnClickInEmptyContent = options.get(EditorOption.unfoldOnClickInEmptyContent);
135+
}
131136
}));
132137
this.onModelChanged();
133138
}
@@ -364,6 +369,15 @@ export class FoldingController extends Disposable implements IEditorContribution
364369

365370
iconClicked = true;
366371
break;
372+
case MouseTargetType.CONTENT_EMPTY: {
373+
if (this._unfoldOnClickInEmptyContent && this.hiddenRangeModel.hasRanges()) {
374+
const data = e.target.detail as IEmptyContentData;
375+
if (!data.isAfterLines) {
376+
break;
377+
}
378+
}
379+
return;
380+
}
367381
case MouseTargetType.CONTENT_TEXT: {
368382
if (this.hiddenRangeModel.hasRanges()) {
369383
let model = this.editor.getModel();

0 commit comments

Comments
 (0)