Skip to content

Commit e337c02

Browse files
authored
Edit showFoldingControls to have a never setting (microsoft#153764)
1 parent 0284e1b commit e337c02

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export interface IEditorOptions {
563563
* Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
564564
* Defaults to 'mouseover'.
565565
*/
566-
showFoldingControls?: 'always' | 'mouseover';
566+
showFoldingControls?: 'always' | 'never' | 'mouseover';
567567
/**
568568
* Controls whether clicking on the empty content after a folded line will unfold the line.
569569
* Defaults to false.
@@ -2331,6 +2331,7 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
23312331

23322332
const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth);
23332333
const folding = options.get(EditorOption.folding);
2334+
const showFoldingDecoration = options.get(EditorOption.showFoldingControls) !== 'never';
23342335

23352336
let lineDecorationsWidth: number;
23362337
if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) {
@@ -2339,7 +2340,7 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
23392340
} else {
23402341
lineDecorationsWidth = EditorIntOption.clampedInt(rawLineDecorationsWidth, 0, 0, 1000);
23412342
}
2342-
if (folding) {
2343+
if (folding && showFoldingDecoration) {
23432344
lineDecorationsWidth += 16;
23442345
}
23452346

@@ -5039,11 +5040,12 @@ export const EditorOptions = {
50395040
)),
50405041
showFoldingControls: register(new EditorStringEnumOption(
50415042
EditorOption.showFoldingControls, 'showFoldingControls',
5042-
'mouseover' as 'always' | 'mouseover',
5043-
['always', 'mouseover'] as const,
5043+
'mouseover' as 'always' | 'never' | 'mouseover',
5044+
['always', 'never', 'mouseover'] as const,
50445045
{
50455046
enumDescriptions: [
50465047
nls.localize('showFoldingControls.always', "Always show the folding controls."),
5048+
nls.localize('showFoldingControls.never', "Never show the folding controls and reduce the gutter size."),
50475049
nls.localize('showFoldingControls.mouseover', "Only show the folding controls when the mouse is over the gutter."),
50485050
],
50495051
description: nls.localize('showFoldingControls', "Controls when the folding controls on the gutter are shown.")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class FoldingController extends Disposable implements IEditorContribution
127127
this.mouseDownInfo = null;
128128

129129
this.foldingDecorationProvider = new FoldingDecorationProvider(editor);
130-
this.foldingDecorationProvider.autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
130+
this.foldingDecorationProvider.showFoldingControls = options.get(EditorOption.showFoldingControls);
131131
this.foldingDecorationProvider.showFoldingHighlights = options.get(EditorOption.foldingHighlight);
132132
this.foldingEnabled = CONTEXT_FOLDING_ENABLED.bindTo(this.contextKeyService);
133133
this.foldingEnabled.set(this._isEnabled);
@@ -159,7 +159,7 @@ export class FoldingController extends Disposable implements IEditorContribution
159159
}
160160
if (e.hasChanged(EditorOption.showFoldingControls) || e.hasChanged(EditorOption.foldingHighlight)) {
161161
const options = this.editor.getOptions();
162-
this.foldingDecorationProvider.autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
162+
this.foldingDecorationProvider.showFoldingControls = options.get(EditorOption.showFoldingControls);
163163
this.foldingDecorationProvider.showFoldingHighlights = options.get(EditorOption.foldingHighlight);
164164
this.triggerFoldingModelChanged();
165165
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ export class FoldingDecorationProvider implements IDecorationProvider {
5252
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
5353
});
5454

55-
public autoHideFoldingControls: boolean = true;
55+
public showFoldingControls: 'always' | 'never' | 'mouseover' = 'mouseover';
5656

5757
public showFoldingHighlights: boolean = true;
5858

5959
constructor(private readonly editor: ICodeEditor) {
6060
}
6161

6262
getDecorationOption(isCollapsed: boolean, isHidden: boolean): ModelDecorationOptions {
63-
if (isHidden) {
63+
if (isHidden || this.showFoldingControls === 'never') {
6464
return FoldingDecorationProvider.HIDDEN_RANGE_DECORATION;
6565
}
6666
if (isCollapsed) {
6767
return this.showFoldingHighlights ? FoldingDecorationProvider.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION : FoldingDecorationProvider.COLLAPSED_VISUAL_DECORATION;
68-
} else if (this.autoHideFoldingControls) {
68+
} else if (this.showFoldingControls === 'mouseover') {
6969
return FoldingDecorationProvider.EXPANDED_AUTO_HIDE_VISUAL_DECORATION;
7070
} else {
7171
return FoldingDecorationProvider.EXPANDED_VISUAL_DECORATION;

src/vs/monaco.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ declare namespace monaco.editor {
33253325
* Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
33263326
* Defaults to 'mouseover'.
33273327
*/
3328-
showFoldingControls?: 'always' | 'mouseover';
3328+
showFoldingControls?: 'always' | 'never' | 'mouseover';
33293329
/**
33303330
* Controls whether clicking on the empty content after a folded line will unfold the line.
33313331
* Defaults to false.
@@ -4539,7 +4539,7 @@ declare namespace monaco.editor {
45394539
selectionClipboard: IEditorOption<EditorOption.selectionClipboard, boolean>;
45404540
selectionHighlight: IEditorOption<EditorOption.selectionHighlight, boolean>;
45414541
selectOnLineNumbers: IEditorOption<EditorOption.selectOnLineNumbers, boolean>;
4542-
showFoldingControls: IEditorOption<EditorOption.showFoldingControls, 'always' | 'mouseover'>;
4542+
showFoldingControls: IEditorOption<EditorOption.showFoldingControls, 'always' | 'never' | 'mouseover'>;
45434543
showUnused: IEditorOption<EditorOption.showUnused, boolean>;
45444544
showDeprecated: IEditorOption<EditorOption.showDeprecated, boolean>;
45454545
inlayHints: IEditorOption<EditorOption.inlayHints, Readonly<Required<IEditorInlayHintsOptions>>>;

src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ export class CommentController implements IEditorContribution {
859859
}
860860

861861
const options = this.editor.getOptions();
862-
if (options.get(EditorOption.folding)) {
862+
if (options.get(EditorOption.folding) && options.get(EditorOption.showFoldingControls) !== 'never') {
863863
lineDecorationsWidth -= 16;
864864
}
865865
lineDecorationsWidth += 9;

src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,10 @@ configurationRegistry.registerConfiguration({
846846
[NotebookSetting.showFoldingControls]: {
847847
description: nls.localize('notebook.showFoldingControls.description', "Controls when the Markdown header folding arrow is shown."),
848848
type: 'string',
849-
enum: ['always', 'mouseover'],
849+
enum: ['always', 'never', 'mouseover'],
850850
enumDescriptions: [
851851
nls.localize('showFoldingControls.always', "The folding controls are always visible."),
852+
nls.localize('showFoldingControls.never', "Never show the folding controls and reduce the gutter size."),
852853
nls.localize('showFoldingControls.mouseover', "The folding controls are visible only on mouseover."),
853854
],
854855
default: 'mouseover',

src/vs/workbench/contrib/notebook/common/notebookOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface NotebookLayoutConfiguration {
5959
globalToolbar: boolean;
6060
consolidatedOutputButton: boolean;
6161
consolidatedRunButton: boolean;
62-
showFoldingControls: 'always' | 'mouseover';
62+
showFoldingControls: 'always' | 'never' | 'mouseover';
6363
dragAndDropEnabled: boolean;
6464
fontSize: number;
6565
outputFontSize: number;
@@ -385,7 +385,7 @@ export class NotebookOptions extends Disposable {
385385
}
386386

387387
private _computeShowFoldingControlsOption() {
388-
return this.configurationService.getValue<'always' | 'mouseover'>(NotebookSetting.showFoldingControls) ?? 'mouseover';
388+
return this.configurationService.getValue<'always' | 'never' | 'mouseover'>(NotebookSetting.showFoldingControls) ?? 'mouseover';
389389
}
390390

391391
private _computeFocusIndicatorOption() {

0 commit comments

Comments
 (0)