Skip to content

Commit f1f645f

Browse files
committed
editor.guides.bracketPairs: 'active' | 'all' | 'none' -> boolean | 'active'
1 parent 78d2262 commit f1f645f

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
105105
// --- end event handlers
106106

107107
public prepareRender(ctx: RenderingContext): void {
108-
if (!this._bracketPairGuideOptions.indentation && !this._bracketPairGuideOptions.bracketPairs) {
108+
if (!this._bracketPairGuideOptions.indentation && this._bracketPairGuideOptions.bracketPairs === false) {
109109
this._renderResult = null;
110110
return;
111111
}
@@ -155,19 +155,19 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
155155
visibleEndLineNumber: number,
156156
activeCursorPosition: Position | null
157157
): IndentGuide[][] {
158-
const bracketGuides = this._bracketPairGuideOptions.bracketPairs !== 'none'
158+
const bracketGuides = this._bracketPairGuideOptions.bracketPairs !== false
159159
? this._context.model.getBracketGuidesInRangeByLine(
160160
visibleStartLineNumber,
161161
visibleEndLineNumber,
162162
activeCursorPosition,
163163
{
164164
highlightActive: this._bracketPairGuideOptions.highlightActiveBracketPair,
165-
horizontalGuides: this._bracketPairGuideOptions.bracketPairsHorizontal === 'all'
165+
horizontalGuides: this._bracketPairGuideOptions.bracketPairsHorizontal === true
166166
? HorizontalGuidesState.Enabled
167167
: this._bracketPairGuideOptions.bracketPairsHorizontal === 'active'
168168
? HorizontalGuidesState.EnabledForActive
169169
: HorizontalGuidesState.Disabled,
170-
includeInactive: this._bracketPairGuideOptions.bracketPairs === 'all',
170+
includeInactive: this._bracketPairGuideOptions.bracketPairs === true,
171171
}
172172
)
173173
: null;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@ function migrateOptions(options: IEditorOptions): void {
278278
};
279279
if (!options.guides) {
280280
options.guides = {};
281-
} else {
282-
// migrate bracketPairs: boolean -> : 'all' | 'active' | 'none'
283-
if (options.guides.bracketPairs as any === true) {
284-
options.guides.bracketPairs = 'all';
285-
}
286281
}
287282

288283
if (renderIndentGuides !== undefined) {

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,15 +3347,15 @@ class BracketPairColorization extends BaseEditorOption<EditorOption.bracketPairC
33473347
export interface IGuidesOptions {
33483348
/**
33493349
* Enable rendering of bracket pair guides.
3350-
* Defaults to 'none'.
3350+
* Defaults to false.
33513351
*/
3352-
bracketPairs?: 'all' | 'active' | 'none';
3352+
bracketPairs?: boolean | 'active';
33533353

33543354
/**
33553355
* Enable rendering of vertical bracket pair guides.
33563356
* Defaults to 'active'.
33573357
*/
3358-
bracketPairsHorizontal?: 'all' | 'active' | 'none';
3358+
bracketPairsHorizontal?: boolean | 'active';
33593359

33603360
/**
33613361
* Enable highlighting of the active bracket pair.
@@ -3387,7 +3387,7 @@ export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>;
33873387
class GuideOptions extends BaseEditorOption<EditorOption.guides, InternalGuidesOptions> {
33883388
constructor() {
33893389
const defaults: InternalGuidesOptions = {
3390-
bracketPairs: 'none',
3390+
bracketPairs: false,
33913391
bracketPairsHorizontal: 'active',
33923392
highlightActiveBracketPair: true,
33933393

@@ -3399,14 +3399,14 @@ class GuideOptions extends BaseEditorOption<EditorOption.guides, InternalGuidesO
33993399
EditorOption.guides, 'guides', defaults,
34003400
{
34013401
'editor.guides.bracketPairs': {
3402-
type: 'string',
3403-
enum: ['all', 'active', 'none'],
3402+
type: ['boolean', 'string'],
3403+
enum: [true, 'active', false],
34043404
default: defaults.bracketPairs,
34053405
description: nls.localize('editor.guides.bracketPairs', "Controls whether bracket pair guides are enabled or not.")
34063406
},
34073407
'editor.guides.bracketPairsHorizontal': {
3408-
type: 'string',
3409-
enum: ['all', 'active', 'none'],
3408+
type: ['boolean', 'string'],
3409+
enum: [true, 'active', false],
34103410
default: defaults.bracketPairsHorizontal,
34113411
description: nls.localize('editor.guides.bracketPairsHorizontal', "Controls whether horizontal bracket pair guides are enabled or not.")
34123412
},
@@ -3435,8 +3435,8 @@ class GuideOptions extends BaseEditorOption<EditorOption.guides, InternalGuidesO
34353435
}
34363436
const input = _input as IGuidesOptions;
34373437
return {
3438-
bracketPairs: stringSet(input.bracketPairs, this.defaultValue.bracketPairs, ['all', 'active', 'none']),
3439-
bracketPairsHorizontal: stringSet(input.bracketPairsHorizontal, this.defaultValue.bracketPairsHorizontal, ['all', 'active', 'none']),
3438+
bracketPairs: primitiveSet(input.bracketPairs, this.defaultValue.bracketPairs, [true, false, 'active']),
3439+
bracketPairsHorizontal: primitiveSet(input.bracketPairsHorizontal, this.defaultValue.bracketPairsHorizontal, [true, false, 'active']),
34403440
highlightActiveBracketPair: boolean(input.highlightActiveBracketPair, this.defaultValue.highlightActiveBracketPair),
34413441

34423442
indentation: boolean(input.indentation, this.defaultValue.indentation),
@@ -3445,6 +3445,14 @@ class GuideOptions extends BaseEditorOption<EditorOption.guides, InternalGuidesO
34453445
}
34463446
}
34473447

3448+
function primitiveSet<T extends string | boolean>(value: unknown, defaultValue: T, allowedValues: T[]): T {
3449+
const idx = allowedValues.indexOf(value as any);
3450+
if (idx === -1) {
3451+
return defaultValue;
3452+
}
3453+
return allowedValues[idx];
3454+
}
3455+
34483456
//#endregion
34493457

34503458
//#region suggest

src/vs/monaco.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,14 +3864,14 @@ declare namespace monaco.editor {
38643864
export interface IGuidesOptions {
38653865
/**
38663866
* Enable rendering of bracket pair guides.
3867-
* Defaults to 'none'.
3867+
* Defaults to false.
38683868
*/
3869-
bracketPairs?: 'all' | 'active' | 'none';
3869+
bracketPairs?: boolean | 'active';
38703870
/**
38713871
* Enable rendering of vertical bracket pair guides.
38723872
* Defaults to 'active'.
38733873
*/
3874-
bracketPairsHorizontal?: 'all' | 'active' | 'none';
3874+
bracketPairsHorizontal?: boolean | 'active';
38753875
/**
38763876
* Enable highlighting of the active bracket pair.
38773877
* Defaults to true.

0 commit comments

Comments
 (0)