提交 f886259e 编写于 作者: A Alex Dima

Fixes #5351: Add editor.occurrencesHighlight option

上级 e7292265
......@@ -315,6 +315,7 @@ class InternalEditorOptionsHelper {
suggestFontSize: opts.suggestFontSize,
suggestLineHeight: opts.suggestLineHeight,
selectionHighlight: toBoolean(opts.selectionHighlight),
occurrencesHighlight: toBoolean(opts.occurrencesHighlight),
codeLens: opts.referenceInfos && opts.codeLens,
folding: toBoolean(opts.folding),
matchBrackets: toBoolean(opts.matchBrackets),
......@@ -797,6 +798,11 @@ const editorConfiguration: IConfigurationNode = {
'default': DefaultConfig.editor.selectionHighlight,
'description': nls.localize('selectionHighlight', "Controls whether the editor should highlight similar matches to the selection")
},
'editor.occurrencesHighlight': {
'type': 'boolean',
'default': DefaultConfig.editor.occurrencesHighlight,
'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences")
},
'editor.overviewRulerLanes': {
'type': 'integer',
'default': 3,
......
......@@ -100,6 +100,7 @@ class ConfigClass implements IConfiguration {
suggestFontSize: 0,
suggestLineHeight: 0,
selectionHighlight: true,
occurrencesHighlight: true,
codeLens: true,
referenceInfos: true,
folding: true,
......
......@@ -485,6 +485,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
selectionHighlight?: boolean;
/**
* Enable semantic occurrences highlight.
* Defaults to true.
*/
occurrencesHighlight?: boolean;
/**
* Show code lens
* Defaults to true.
......@@ -996,6 +1001,7 @@ export class EditorContribOptions {
readonly suggestFontSize: number;
readonly suggestLineHeight: number;
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
readonly codeLens: boolean;
readonly folding: boolean;
readonly matchBrackets: boolean;
......@@ -1022,6 +1028,7 @@ export class EditorContribOptions {
suggestFontSize: number;
suggestLineHeight: number;
selectionHighlight: boolean;
occurrencesHighlight: boolean;
codeLens: boolean;
folding: boolean;
matchBrackets: boolean;
......@@ -1044,6 +1051,7 @@ export class EditorContribOptions {
this.suggestFontSize = source.suggestFontSize;
this.suggestLineHeight = source.suggestLineHeight;
this.selectionHighlight = Boolean(source.selectionHighlight);
this.occurrencesHighlight = Boolean(source.occurrencesHighlight);
this.codeLens = Boolean(source.codeLens);
this.folding = Boolean(source.folding);
this.matchBrackets = Boolean(source.matchBrackets);
......@@ -1072,6 +1080,7 @@ export class EditorContribOptions {
&& this.suggestFontSize === other.suggestFontSize
&& this.suggestLineHeight === other.suggestLineHeight
&& this.selectionHighlight === other.selectionHighlight
&& this.occurrencesHighlight === other.occurrencesHighlight
&& this.codeLens === other.codeLens
&& this.folding === other.folding
&& this.matchBrackets === other.matchBrackets
......
......@@ -49,6 +49,7 @@ CommonEditorRegistry.registerDefaultLanguageCommand('_executeDocumentHighlights'
class WordHighlighter {
private editor: editorCommon.ICommonCodeEditor;
private occurrencesHighlight: boolean;
private model: editorCommon.IModel;
private _lastWordRange: Range;
private _decorationIds: string[];
......@@ -64,6 +65,7 @@ class WordHighlighter {
constructor(editor: editorCommon.ICommonCodeEditor) {
this.editor = editor;
this.occurrencesHighlight = this.editor.getConfiguration().contribInfo.occurrencesHighlight;
this.model = this.editor.getModel();
this.toUnhook = [];
this.toUnhook.push(editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => {
......@@ -76,6 +78,13 @@ class WordHighlighter {
this.toUnhook.push(editor.onDidChangeModelContent((e) => {
this._stopAll();
}));
this.toUnhook.push(editor.onDidChangeConfiguration((e) => {
let newValue = this.editor.getConfiguration().contribInfo.occurrencesHighlight;
if (this.occurrencesHighlight !== newValue) {
this.occurrencesHighlight = newValue;
this._stopAll();
}
}));
this._lastWordRange = null;
this._decorationIds = [];
......@@ -121,6 +130,12 @@ class WordHighlighter {
private _onPositionChanged(e: editorCommon.ICursorPositionChangedEvent): void {
// disabled
if (!this.occurrencesHighlight) {
this._stopAll();
return;
}
// ignore typing & other
if (e.reason !== editorCommon.CursorChangeReason.Explicit) {
this._stopAll();
......
......@@ -1409,6 +1409,11 @@ declare module monaco.editor {
* Defaults to true.
*/
selectionHighlight?: boolean;
/**
* Enable semantic occurrences highlight.
* Defaults to true.
*/
occurrencesHighlight?: boolean;
/**
* Show code lens
* Defaults to true.
......@@ -1612,6 +1617,7 @@ declare module monaco.editor {
readonly suggestFontSize: number;
readonly suggestLineHeight: number;
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
readonly codeLens: boolean;
readonly folding: boolean;
readonly matchBrackets: boolean;
......
......@@ -243,6 +243,7 @@ const configurationValueWhitelist = [
'editor.quickSuggestionsDelay',
'editor.snippetSuggestions',
'editor.selectionHighlight',
'editor.occurrencesHighlight',
'editor.glyphMargin',
'editor.wordSeparators',
'editor.mouseWheelScrollSensitivity',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册