Skip to content

Commit

Permalink
Merge pull request #19978 from chirag64/matching-brackets-highlight
Browse files Browse the repository at this point in the history
Fixes #16424 - Added option to toggle matching brackets highlighter
  • Loading branch information
alexdima committed Feb 20, 2017
2 parents a734c13 + 7632578 commit 175c91b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class InternalEditorOptionsHelper {
selectionHighlight: toBoolean(opts.selectionHighlight),
codeLens: opts.referenceInfos && opts.codeLens,
folding: toBoolean(opts.folding),
highlightMatchingBrackets: toBoolean(opts.highlightMatchingBrackets),
});

return new editorCommon.InternalEditorOptions({
Expand Down Expand Up @@ -822,6 +823,11 @@ const editorConfiguration: IConfigurationNode = {
'default': DefaultConfig.editor.folding,
'description': nls.localize('folding', "Controls whether the editor has code folding enabled")
},
'editor.highlightMatchingBrackets': {
'type': 'boolean',
'default': true,
'description': nls.localize('highlightMatchingBrackets', "Highlight matching brackets when one of them is selected.")
},
'editor.glyphMargin': {
'type': 'boolean',
'default': DefaultConfig.editor.glyphMargin,
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/common/config/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class ConfigClass implements IConfiguration {
renderIndentGuides: false,
renderLineHighlight: 'line',
useTabStops: true,
highlightMatchingBrackets: true,

fontFamily: (
platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)
Expand Down
9 changes: 9 additions & 0 deletions src/vs/editor/common/editorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ export interface IEditorOptions {
* Defaults to true in vscode and to false in monaco-editor.
*/
folding?: boolean;
/**
* Enable to highlight matching brackets.
* Defaults to true.
*/
highlightMatchingBrackets?: boolean;
/**
* Enable rendering of whitespace.
* Defaults to none.
Expand Down Expand Up @@ -966,6 +971,7 @@ export class EditorContribOptions {
readonly selectionHighlight: boolean;
readonly codeLens: boolean;
readonly folding: boolean;
readonly highlightMatchingBrackets: boolean;

/**
* @internal
Expand All @@ -992,6 +998,7 @@ export class EditorContribOptions {
selectionHighlight: boolean;
codeLens: boolean;
folding: boolean;
highlightMatchingBrackets: boolean;
}) {
this.selectionClipboard = Boolean(source.selectionClipboard);
this.hover = Boolean(source.hover);
Expand All @@ -1014,6 +1021,7 @@ export class EditorContribOptions {
this.selectionHighlight = Boolean(source.selectionHighlight);
this.codeLens = Boolean(source.codeLens);
this.folding = Boolean(source.folding);
this.highlightMatchingBrackets = Boolean(source.highlightMatchingBrackets);
}

/**
Expand Down Expand Up @@ -1042,6 +1050,7 @@ export class EditorContribOptions {
&& this.selectionHighlight === other.selectionHighlight
&& this.codeLens === other.codeLens
&& this.folding === other.folding
&& this.highlightMatchingBrackets === other.highlightMatchingBrackets
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Position } from 'vs/editor/common/core/position';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { editorAction, commonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

import EditorContextKeys = editorCommon.EditorContextKeys;

Expand Down Expand Up @@ -67,7 +68,10 @@ export class BracketMatchingController extends Disposable implements editorCommo
private _decorations: string[];
private _updateBracketsSoon: RunOnceScheduler;

constructor(editor: editorCommon.ICommonCodeEditor) {
constructor(
editor: editorCommon.ICommonCodeEditor,
@IConfigurationService private configurationService: IConfigurationService
) {
super();
this._editor = editor;
this._lastBracketsData = [];
Expand Down Expand Up @@ -125,7 +129,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
let newDecorations: editorCommon.IModelDeltaDecoration[] = [], newDecorationsLen = 0;
for (let i = 0, len = this._lastBracketsData.length; i < len; i++) {
let brackets = this._lastBracketsData[i].brackets;
if (brackets) {
if (this.configurationService.lookup<boolean>('editor.highlightMatchingBrackets').value && brackets) {
newDecorations[newDecorationsLen++] = { range: brackets[0], options: BracketMatchingController._DECORATION_OPTIONS };
newDecorations[newDecorationsLen++] = { range: brackets[1], options: BracketMatchingController._DECORATION_OPTIONS };
}
Expand Down
6 changes: 6 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,11 @@ declare module monaco.editor {
* Defaults to true in vscode and to false in monaco-editor.
*/
folding?: boolean;
/**
* Enable to highlight matching brackets
* Defaults to true
*/
highlightMatchingBrackets?: boolean;
/**
* Enable rendering of whitespace.
* Defaults to none.
Expand Down Expand Up @@ -1585,6 +1590,7 @@ declare module monaco.editor {
readonly selectionHighlight: boolean;
readonly codeLens: boolean;
readonly folding: boolean;
readonly highlightMatchingBrackets: boolean;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/telemetry/common/telemetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const configurationValueWhitelist = [
'editor.hideCursorInOverviewRuler',
'editor.trimAutoWhitespace',
'editor.folding',
'editor.highlightMatchingBrackets',
'workbench.editor.enablePreviewFromQuickOpen',
'php.builtInCompletions.enable',
'php.validate.enable',
Expand Down

0 comments on commit 175c91b

Please sign in to comment.