mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 19:48:09 +00:00
Convert more editor options
This commit is contained in:
parent
e787da13c3
commit
2adf01f2af
23 changed files with 649 additions and 685 deletions
|
@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event';
|
|||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
|
||||
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
|
@ -116,59 +116,76 @@ export class EditorConfiguration2 {
|
|||
* Compatibility with old options
|
||||
*/
|
||||
function migrateOptions(options: IEditorOptions): void {
|
||||
let wordWrap = options.wordWrap;
|
||||
const wordWrap = options.wordWrap;
|
||||
if (<any>wordWrap === true) {
|
||||
options.wordWrap = 'on';
|
||||
} else if (<any>wordWrap === false) {
|
||||
options.wordWrap = 'off';
|
||||
}
|
||||
|
||||
let lineNumbers = options.lineNumbers;
|
||||
const lineNumbers = options.lineNumbers;
|
||||
if (<any>lineNumbers === true) {
|
||||
options.lineNumbers = 'on';
|
||||
} else if (<any>lineNumbers === false) {
|
||||
options.lineNumbers = 'off';
|
||||
}
|
||||
|
||||
let autoClosingBrackets = options.autoClosingBrackets;
|
||||
const autoClosingBrackets = options.autoClosingBrackets;
|
||||
if (<any>autoClosingBrackets === false) {
|
||||
options.autoClosingBrackets = 'never';
|
||||
options.autoClosingQuotes = 'never';
|
||||
options.autoSurround = 'never';
|
||||
}
|
||||
|
||||
let cursorBlinking = options.cursorBlinking;
|
||||
const cursorBlinking = options.cursorBlinking;
|
||||
if (<any>cursorBlinking === 'visible') {
|
||||
options.cursorBlinking = 'solid';
|
||||
}
|
||||
|
||||
let renderWhitespace = options.renderWhitespace;
|
||||
const renderWhitespace = options.renderWhitespace;
|
||||
if (<any>renderWhitespace === true) {
|
||||
options.renderWhitespace = 'boundary';
|
||||
} else if (<any>renderWhitespace === false) {
|
||||
options.renderWhitespace = 'none';
|
||||
}
|
||||
|
||||
let renderLineHighlight = options.renderLineHighlight;
|
||||
const renderLineHighlight = options.renderLineHighlight;
|
||||
if (<any>renderLineHighlight === true) {
|
||||
options.renderLineHighlight = 'line';
|
||||
} else if (<any>renderLineHighlight === false) {
|
||||
options.renderLineHighlight = 'none';
|
||||
}
|
||||
|
||||
let acceptSuggestionOnEnter = options.acceptSuggestionOnEnter;
|
||||
const acceptSuggestionOnEnter = options.acceptSuggestionOnEnter;
|
||||
if (<any>acceptSuggestionOnEnter === true) {
|
||||
options.acceptSuggestionOnEnter = 'on';
|
||||
} else if (<any>acceptSuggestionOnEnter === false) {
|
||||
options.acceptSuggestionOnEnter = 'off';
|
||||
}
|
||||
|
||||
const tabCompletion = options.tabCompletion;
|
||||
if (<any>tabCompletion === false) {
|
||||
options.tabCompletion = 'off';
|
||||
} else if (<any>tabCompletion === true) {
|
||||
options.tabCompletion = 'onlySnippets';
|
||||
}
|
||||
|
||||
const hover = options.hover;
|
||||
if (<any>hover === true) {
|
||||
options.hover = {
|
||||
enabled: true
|
||||
};
|
||||
} else if (<any>hover === false) {
|
||||
options.hover = {
|
||||
enabled: false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
|
||||
|
||||
public readonly isSimpleWidget: boolean;
|
||||
protected _rawOptions: IEditorOptions;
|
||||
protected _validatedOptions: IValidatedEditorOptions;
|
||||
public editor!: InternalEditorOptions;
|
||||
private _isDominatedByLongLines: boolean;
|
||||
private _lineNumbersDigitCount: number;
|
||||
|
@ -194,8 +211,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
|
|||
this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {});
|
||||
this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {});
|
||||
|
||||
this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
|
||||
|
||||
this._rawOptions2 = EditorConfiguration2.readOptions(options);
|
||||
this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2);
|
||||
|
||||
|
@ -237,7 +252,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
|
|||
}
|
||||
|
||||
private _computeInternalOptions(): [InternalEditorOptions, ComputedEditorOptions] {
|
||||
const opts = this._validatedOptions;
|
||||
const partialEnv = this._getEnvConfiguration();
|
||||
const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget);
|
||||
const env: IEnvironmentalOptions = {
|
||||
|
@ -252,7 +266,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
|
|||
tabFocusMode: TabFocus.getTabFocusMode(),
|
||||
accessibilitySupport: partialEnv.accessibilitySupport
|
||||
};
|
||||
const r = InternalEditorOptionsFactory.createInternalEditorOptions(env, opts);
|
||||
const r = InternalEditorOptionsFactory.createInternalEditorOptions(env);
|
||||
const r2 = EditorConfiguration2.computeOptions(this._validatedOptions2, env);
|
||||
return [r, r2];
|
||||
}
|
||||
|
@ -308,7 +322,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
|
|||
this._rawOptions = objects.mixin(this._rawOptions, newOptions || {});
|
||||
this._rawOptions2 = EditorConfiguration2.mixOptions(this._rawOptions2, newOptions);
|
||||
|
||||
this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
|
||||
this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2);
|
||||
|
||||
this._recomputeOptions();
|
||||
|
@ -491,32 +504,32 @@ const editorConfiguration: IConfigurationNode = {
|
|||
},
|
||||
'editor.hover.enabled': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.hover.enabled,
|
||||
'default': EditorOptions.hover.defaultValue.enabled,
|
||||
'description': nls.localize('hover.enabled', "Controls whether the hover is shown.")
|
||||
},
|
||||
'editor.hover.delay': {
|
||||
'type': 'number',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.hover.delay,
|
||||
'default': EditorOptions.hover.defaultValue.delay,
|
||||
'description': nls.localize('hover.delay', "Controls the delay in milliseconds after which the hover is shown.")
|
||||
},
|
||||
'editor.hover.sticky': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.hover.sticky,
|
||||
'default': EditorOptions.hover.defaultValue.sticky,
|
||||
'description': nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.")
|
||||
},
|
||||
'editor.find.seedSearchStringFromSelection': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection,
|
||||
'default': EditorOptions.find.defaultValue.seedSearchStringFromSelection,
|
||||
'description': nls.localize('find.seedSearchStringFromSelection', "Controls whether the search string in the Find Widget is seeded from the editor selection.")
|
||||
},
|
||||
'editor.find.autoFindInSelection': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.find.autoFindInSelection,
|
||||
'default': EditorOptions.find.defaultValue.autoFindInSelection,
|
||||
'description': nls.localize('find.autoFindInSelection', "Controls whether the find operation is carried out on selected text or the entire file in the editor.")
|
||||
},
|
||||
'editor.find.globalFindClipboard': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.find.globalFindClipboard,
|
||||
'default': EditorOptions.find.defaultValue.globalFindClipboard,
|
||||
'description': nls.localize('find.globalFindClipboard', "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."),
|
||||
'included': platform.isMacintosh
|
||||
},
|
||||
|
@ -635,7 +648,7 @@ const editorConfiguration: IConfigurationNode = {
|
|||
}
|
||||
}
|
||||
],
|
||||
'default': EDITOR_DEFAULTS.contribInfo.quickSuggestions,
|
||||
'default': EditorOptions.quickSuggestions.defaultValue,
|
||||
'description': nls.localize('quickSuggestions', "Controls whether suggestions should automatically show up while typing.")
|
||||
},
|
||||
'editor.quickSuggestionsDelay': {
|
||||
|
@ -646,12 +659,12 @@ const editorConfiguration: IConfigurationNode = {
|
|||
},
|
||||
'editor.parameterHints.enabled': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.enabled,
|
||||
'default': EditorOptions.parameterHints.defaultValue.enabled,
|
||||
'description': nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.")
|
||||
},
|
||||
'editor.parameterHints.cycle': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.cycle,
|
||||
'default': EditorOptions.parameterHints.defaultValue.cycle,
|
||||
'description': nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
|
||||
},
|
||||
'editor.autoClosingBrackets': {
|
||||
|
@ -746,7 +759,7 @@ const editorConfiguration: IConfigurationNode = {
|
|||
nls.localize('snippetSuggestions.inline', "Show snippets suggestions with other suggestions."),
|
||||
nls.localize('snippetSuggestions.none', "Do not show snippet suggestions."),
|
||||
],
|
||||
'default': EDITOR_DEFAULTS.contribInfo.suggest.snippets,
|
||||
'default': EditorOptions.snippetSuggestions.defaultValue,
|
||||
'description': nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.")
|
||||
},
|
||||
'editor.emptySelectionClipboard': {
|
||||
|
@ -761,7 +774,7 @@ const editorConfiguration: IConfigurationNode = {
|
|||
},
|
||||
'editor.wordBasedSuggestions': {
|
||||
'type': 'boolean',
|
||||
'default': EditorOptions.wordBasedSuggestions.defaultValue,
|
||||
'default': true,
|
||||
'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
|
||||
},
|
||||
'editor.suggestSelection': {
|
||||
|
@ -820,12 +833,12 @@ const editorConfiguration: IConfigurationNode = {
|
|||
},
|
||||
'editor.suggest.showIcons': {
|
||||
type: 'boolean',
|
||||
default: EDITOR_DEFAULTS.contribInfo.suggest.showIcons,
|
||||
default: EditorOptions.suggest.defaultValue.showIcons,
|
||||
description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
|
||||
},
|
||||
'editor.suggest.maxVisibleSuggestions': {
|
||||
type: 'number',
|
||||
default: EDITOR_DEFAULTS.contribInfo.suggest.maxVisibleSuggestions,
|
||||
default: EditorOptions.suggest.defaultValue.maxVisibleSuggestions,
|
||||
minimum: 1,
|
||||
maximum: 15,
|
||||
description: nls.localize('suggest.maxVisibleSuggestions', "Controls how many suggestions IntelliSense will show before showing a scrollbar (maximum 15).")
|
||||
|
@ -971,7 +984,7 @@ const editorConfiguration: IConfigurationNode = {
|
|||
description: nls.localize('editor.gotoLocation.multiple', "Controls the behavior of 'Go To' commands, like Go To Definition, when multiple target locations exist."),
|
||||
type: 'string',
|
||||
enum: ['peek', 'gotoAndPeek', 'goto'],
|
||||
default: EDITOR_DEFAULTS.contribInfo.gotoLocation.multiple,
|
||||
default: EditorOptions.gotoLocation.defaultValue.multiple,
|
||||
enumDescriptions: [
|
||||
nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
|
||||
nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a peek view'),
|
||||
|
@ -1087,13 +1100,13 @@ const editorConfiguration: IConfigurationNode = {
|
|||
'editor.foldingStrategy': {
|
||||
'type': 'string',
|
||||
'enum': ['auto', 'indentation'],
|
||||
'default': EDITOR_DEFAULTS.contribInfo.foldingStrategy,
|
||||
'default': EditorOptions.foldingStrategy.defaultValue,
|
||||
'markdownDescription': nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges. `auto` uses a language specific folding strategy, if available. `indentation` uses the indentation based folding strategy.")
|
||||
},
|
||||
'editor.showFoldingControls': {
|
||||
'type': 'string',
|
||||
'enum': ['always', 'mouseover'],
|
||||
'default': EDITOR_DEFAULTS.contribInfo.showFoldingControls,
|
||||
'default': EditorOptions.showFoldingControls.defaultValue,
|
||||
'description': nls.localize('showFoldingControls', "Controls whether the fold controls on the gutter are automatically hidden.")
|
||||
},
|
||||
'editor.matchBrackets': {
|
||||
|
@ -1177,12 +1190,12 @@ const editorConfiguration: IConfigurationNode = {
|
|||
'additionalProperties': {
|
||||
'type': 'boolean'
|
||||
},
|
||||
'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSave,
|
||||
'default': {},
|
||||
'description': nls.localize('codeActionsOnSave', "Code action kinds to be run on save.")
|
||||
},
|
||||
'editor.codeActionsOnSaveTimeout': {
|
||||
'type': 'number',
|
||||
'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSaveTimeout,
|
||||
'default': 750,
|
||||
'description': nls.localize('codeActionsOnSaveTimeout', "Timeout in milliseconds after which the code actions that are run on save are cancelled.")
|
||||
},
|
||||
'editor.selectionClipboard': {
|
||||
|
|
|
@ -217,7 +217,7 @@ export interface ISuggestOptions {
|
|||
/**
|
||||
* Max suggestions to show in suggestions. Defaults to 12.
|
||||
*/
|
||||
maxVisibleSuggestions?: boolean;
|
||||
maxVisibleSuggestions?: number;
|
||||
/**
|
||||
* Names of suggestion types to filter.
|
||||
*/
|
||||
|
@ -231,11 +231,10 @@ export interface IGotoLocationOptions {
|
|||
multiple?: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration map for codeActionsOnSave
|
||||
*/
|
||||
export interface ICodeActionsOnSaveOptions {
|
||||
[kind: string]: boolean;
|
||||
export interface IQuickSuggestionsOptions {
|
||||
other: boolean;
|
||||
comments: boolean;
|
||||
strings: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,7 +527,7 @@ export interface IEditorOptions {
|
|||
* Enable quick suggestions (shadow suggestions)
|
||||
* Defaults to true.
|
||||
*/
|
||||
quickSuggestions?: boolean | { other: boolean, comments: boolean, strings: boolean };
|
||||
quickSuggestions?: boolean | IQuickSuggestionsOptions;
|
||||
/**
|
||||
* Quick suggestions show delay (in ms)
|
||||
* Defaults to 10 (ms)
|
||||
|
@ -604,10 +603,6 @@ export interface IEditorOptions {
|
|||
* Syntax highlighting is copied.
|
||||
*/
|
||||
copyWithSyntaxHighlighting?: boolean;
|
||||
/**
|
||||
* Enable word based suggestions. Defaults to 'true'
|
||||
*/
|
||||
wordBasedSuggestions?: boolean;
|
||||
/**
|
||||
* The history mode for suggestions.
|
||||
*/
|
||||
|
@ -625,7 +620,7 @@ export interface IEditorOptions {
|
|||
/**
|
||||
* Enable tab completion.
|
||||
*/
|
||||
tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets';
|
||||
tabCompletion?: 'on' | 'off' | 'onlySnippets';
|
||||
/**
|
||||
* Enable selection highlight.
|
||||
* Defaults to true.
|
||||
|
@ -645,10 +640,6 @@ export interface IEditorOptions {
|
|||
* Control the behavior and rendering of the code action lightbulb.
|
||||
*/
|
||||
lightbulb?: IEditorLightbulbOptions;
|
||||
/**
|
||||
* Code action kinds to be run on save.
|
||||
*/
|
||||
codeActionsOnSave?: ICodeActionsOnSaveOptions;
|
||||
/**
|
||||
* Timeout for running code actions on save.
|
||||
*/
|
||||
|
@ -903,68 +894,6 @@ function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'l
|
|||
}
|
||||
}
|
||||
|
||||
export interface InternalEditorFindOptions {
|
||||
readonly seedSearchStringFromSelection: boolean;
|
||||
readonly autoFindInSelection: boolean;
|
||||
readonly addExtraSpaceOnTop: boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
readonly globalFindClipboard: boolean;
|
||||
}
|
||||
|
||||
export interface InternalEditorHoverOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly delay: number;
|
||||
readonly sticky: boolean;
|
||||
}
|
||||
|
||||
export interface InternalGoToLocationOptions {
|
||||
readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
export interface InternalSuggestOptions {
|
||||
readonly filterGraceful: boolean;
|
||||
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
|
||||
readonly snippetsPreventQuickSuggestions: boolean;
|
||||
readonly localityBonus: boolean;
|
||||
readonly shareSuggestSelections: boolean;
|
||||
readonly showIcons: boolean;
|
||||
readonly maxVisibleSuggestions: number;
|
||||
readonly filteredTypes: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export interface InternalParameterHintOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly cycle: boolean;
|
||||
}
|
||||
|
||||
export interface EditorContribOptions {
|
||||
readonly hover: InternalEditorHoverOptions;
|
||||
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
|
||||
readonly parameterHints: InternalParameterHintOptions;
|
||||
readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
|
||||
readonly suggestFontSize: number;
|
||||
readonly suggestLineHeight: number;
|
||||
readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
|
||||
readonly suggest: InternalSuggestOptions;
|
||||
readonly gotoLocation: InternalGoToLocationOptions;
|
||||
readonly foldingStrategy: 'auto' | 'indentation';
|
||||
readonly showFoldingControls: 'always' | 'mouseover';
|
||||
readonly find: InternalEditorFindOptions;
|
||||
readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
|
||||
readonly codeActionsOnSaveTimeout: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validated configuration options for the editor.
|
||||
* This is a 1 to 1 validated/parsed version of IEditorOptions merged on top of the defaults.
|
||||
* @internal
|
||||
*/
|
||||
export interface IValidatedEditorOptions {
|
||||
readonly contribInfo: EditorContribOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal configuration options (transformed or computed) for the editor.
|
||||
*/
|
||||
|
@ -976,7 +905,6 @@ export class InternalEditorOptions {
|
|||
|
||||
// ---- grouped options
|
||||
readonly fontInfo: FontInfo;
|
||||
readonly contribInfo: EditorContribOptions;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -985,12 +913,10 @@ export class InternalEditorOptions {
|
|||
pixelRatio: number;
|
||||
lineHeight: number;
|
||||
fontInfo: FontInfo;
|
||||
contribInfo: EditorContribOptions;
|
||||
}) {
|
||||
this.pixelRatio = source.pixelRatio;
|
||||
this.lineHeight = source.lineHeight | 0;
|
||||
this.fontInfo = source.fontInfo;
|
||||
this.contribInfo = source.contribInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1001,7 +927,6 @@ export class InternalEditorOptions {
|
|||
this.pixelRatio === other.pixelRatio
|
||||
&& this.lineHeight === other.lineHeight
|
||||
&& this.fontInfo.equals(other.fontInfo)
|
||||
&& InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1019,111 +944,8 @@ export class InternalEditorOptions {
|
|||
pixelRatio: (this.pixelRatio !== newOpts.pixelRatio),
|
||||
lineHeight: (this.lineHeight !== newOpts.lineHeight),
|
||||
fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
|
||||
contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo))
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
|
||||
return (
|
||||
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
|
||||
&& a.autoFindInSelection === b.autoFindInSelection
|
||||
&& a.globalFindClipboard === b.globalFindClipboard
|
||||
&& a.addExtraSpaceOnTop === b.addExtraSpaceOnTop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
|
||||
return (
|
||||
a.enabled === b.enabled
|
||||
&& a.cycle === b.cycle
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
|
||||
return (
|
||||
a.enabled === b.enabled
|
||||
&& a.delay === b.delay
|
||||
&& a.sticky === b.sticky
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _equalsSuggestOptions(a: InternalSuggestOptions, b: InternalSuggestOptions): any {
|
||||
if (a === b) {
|
||||
return true;
|
||||
} else if (!a || !b) {
|
||||
return false;
|
||||
} else {
|
||||
return a.filterGraceful === b.filterGraceful
|
||||
&& a.snippets === b.snippets
|
||||
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
|
||||
&& a.localityBonus === b.localityBonus
|
||||
&& a.shareSuggestSelections === b.shareSuggestSelections
|
||||
&& a.showIcons === b.showIcons
|
||||
&& a.maxVisibleSuggestions === b.maxVisibleSuggestions
|
||||
&& objects.equals(a.filteredTypes, b.filteredTypes);
|
||||
}
|
||||
}
|
||||
|
||||
private static _equalsGotoLocationOptions(a: InternalGoToLocationOptions | undefined, b: InternalGoToLocationOptions | undefined): boolean {
|
||||
if (a === b) {
|
||||
return true;
|
||||
} else if (!a || !b) {
|
||||
return false;
|
||||
} else {
|
||||
return a.multiple === b.multiple;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
|
||||
return (
|
||||
this._equalsHoverOptions(a.hover, b.hover)
|
||||
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
|
||||
&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
|
||||
&& a.suggestSelection === b.suggestSelection
|
||||
&& a.suggestFontSize === b.suggestFontSize
|
||||
&& a.suggestLineHeight === b.suggestLineHeight
|
||||
&& a.tabCompletion === b.tabCompletion
|
||||
&& this._equalsSuggestOptions(a.suggest, b.suggest)
|
||||
&& InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation)
|
||||
&& a.foldingStrategy === b.foldingStrategy
|
||||
&& a.showFoldingControls === b.showFoldingControls
|
||||
&& this._equalFindOptions(a.find, b.find)
|
||||
&& objects.equals(a.codeActionsOnSave, b.codeActionsOnSave)
|
||||
&& a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout
|
||||
);
|
||||
}
|
||||
|
||||
private static _equalsQuickSuggestions(a: boolean | { other: boolean, comments: boolean, strings: boolean }, b: boolean | { other: boolean, comments: boolean, strings: boolean }): boolean {
|
||||
if (typeof a === 'boolean') {
|
||||
if (typeof b !== 'boolean') {
|
||||
return false;
|
||||
}
|
||||
return a === b;
|
||||
}
|
||||
if (typeof b === 'boolean') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
a.comments === b.comments
|
||||
&& a.other === b.other
|
||||
&& a.strings === b.strings
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1134,7 +956,6 @@ export interface IConfigurationChangedEvent {
|
|||
readonly pixelRatio: boolean;
|
||||
readonly lineHeight: boolean;
|
||||
readonly fontInfo: boolean;
|
||||
readonly contribInfo: boolean;
|
||||
}
|
||||
|
||||
export interface IEnvironmentalOptions {
|
||||
|
@ -1150,7 +971,7 @@ export interface IEnvironmentalOptions {
|
|||
readonly accessibilitySupport: AccessibilitySupport;
|
||||
}
|
||||
|
||||
function _boolean<T>(value: any, defaultValue: T): boolean | T {
|
||||
function _boolean(value: any, defaultValue: boolean): boolean {
|
||||
if (typeof value === 'undefined') {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -1161,21 +982,6 @@ function _boolean<T>(value: any, defaultValue: T): boolean | T {
|
|||
return Boolean(value);
|
||||
}
|
||||
|
||||
function _booleanMap(value: { [key: string]: boolean } | undefined, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
|
||||
if (!value) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
const out = Object.create(null);
|
||||
for (const k of Object.keys(value)) {
|
||||
const v = value[k];
|
||||
if (typeof v === 'boolean') {
|
||||
out[k] = v;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function _string(value: any, defaultValue: string): string {
|
||||
if (typeof value !== 'string') {
|
||||
return defaultValue;
|
||||
|
@ -1254,134 +1060,16 @@ function _scrollbarVisibilityFromString(visibility: string | undefined, defaultV
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class EditorOptionsValidator {
|
||||
|
||||
/**
|
||||
* Validate raw editor options.
|
||||
* i.e. since they can be defined by the user, they might be invalid.
|
||||
*/
|
||||
public static validate(opts: IEditorOptions, defaults: IValidatedEditorOptions): IValidatedEditorOptions {
|
||||
const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
|
||||
return {
|
||||
contribInfo: contribInfo,
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
|
||||
if (typeof opts !== 'object') {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
return {
|
||||
seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
|
||||
autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection),
|
||||
globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard),
|
||||
addExtraSpaceOnTop: _boolean(opts.addExtraSpaceOnTop, defaults.addExtraSpaceOnTop)
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions | undefined, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
|
||||
if (typeof opts !== 'object') {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
return {
|
||||
enabled: _boolean(opts.enabled, defaults.enabled),
|
||||
cycle: _boolean(opts.cycle, defaults.cycle)
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeHoverOpts(_opts: boolean | IEditorHoverOptions | undefined, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
|
||||
let opts: IEditorHoverOptions;
|
||||
if (typeof _opts === 'boolean') {
|
||||
opts = {
|
||||
enabled: _opts
|
||||
};
|
||||
} else if (typeof _opts === 'object') {
|
||||
opts = _opts;
|
||||
} else {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
return {
|
||||
enabled: _boolean(opts.enabled, defaults.enabled),
|
||||
delay: _clampedInt(opts.delay, defaults.delay, 0, 10000),
|
||||
sticky: _boolean(opts.sticky, defaults.sticky)
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeSuggestOpts(opts: IEditorOptions, defaults: InternalSuggestOptions): InternalSuggestOptions {
|
||||
const suggestOpts = opts.suggest || {};
|
||||
return {
|
||||
filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful),
|
||||
snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
|
||||
snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
|
||||
localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
|
||||
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
|
||||
showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
|
||||
maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 15),
|
||||
filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null)
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions {
|
||||
const gotoOpts = opts.gotoLocation || {};
|
||||
return {
|
||||
multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(gotoOpts.multiple, defaults.multiple, ['peek', 'gotoAndPeek', 'goto'])
|
||||
};
|
||||
}
|
||||
|
||||
private static _sanitizeTabCompletionOpts(opts: boolean | 'on' | 'off' | 'onlySnippets' | undefined, defaults: 'on' | 'off' | 'onlySnippets'): 'on' | 'off' | 'onlySnippets' {
|
||||
if (opts === false) {
|
||||
return 'off';
|
||||
} else if (opts === true) {
|
||||
return 'onlySnippets';
|
||||
} else {
|
||||
return _stringSet<'on' | 'off' | 'onlySnippets'>(opts, defaults, ['on', 'off', 'onlySnippets']);
|
||||
}
|
||||
}
|
||||
|
||||
private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions {
|
||||
let quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
|
||||
if (typeof opts.quickSuggestions === 'object') {
|
||||
quickSuggestions = { other: true, ...opts.quickSuggestions };
|
||||
} else {
|
||||
quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions);
|
||||
}
|
||||
const find = this._sanitizeFindOpts(opts.find, defaults.find);
|
||||
return {
|
||||
hover: this._sanitizeHoverOpts(opts.hover, defaults.hover),
|
||||
quickSuggestions: quickSuggestions,
|
||||
parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
|
||||
suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']),
|
||||
suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
|
||||
suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
|
||||
tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion),
|
||||
suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
|
||||
gotoLocation: this._sanitizeGotoLocationOpts(opts, defaults.gotoLocation),
|
||||
foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']),
|
||||
showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
|
||||
find: find,
|
||||
codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}),
|
||||
codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class InternalEditorOptionsFactory {
|
||||
|
||||
public static createInternalEditorOptions(env: IEnvironmentalOptions, opts: IValidatedEditorOptions) {
|
||||
public static createInternalEditorOptions(env: IEnvironmentalOptions) {
|
||||
return new InternalEditorOptions({
|
||||
pixelRatio: env.pixelRatio,
|
||||
lineHeight: env.fontInfo.lineHeight,
|
||||
fontInfo: env.fontInfo,
|
||||
contribInfo: opts.contribInfo,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1448,55 +1136,6 @@ export const EDITOR_MODEL_DEFAULTS = {
|
|||
largeFileOptimizations: true
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
|
||||
contribInfo: {
|
||||
hover: {
|
||||
enabled: true,
|
||||
delay: 300,
|
||||
sticky: true
|
||||
},
|
||||
quickSuggestions: {
|
||||
other: true,
|
||||
comments: false,
|
||||
strings: false
|
||||
},
|
||||
parameterHints: {
|
||||
enabled: true,
|
||||
cycle: false
|
||||
},
|
||||
suggestSelection: 'recentlyUsed',
|
||||
suggestFontSize: 0,
|
||||
suggestLineHeight: 0,
|
||||
tabCompletion: 'off',
|
||||
suggest: {
|
||||
filterGraceful: true,
|
||||
snippets: 'inline',
|
||||
snippetsPreventQuickSuggestions: true,
|
||||
localityBonus: false,
|
||||
shareSuggestSelections: false,
|
||||
showIcons: true,
|
||||
maxVisibleSuggestions: 12,
|
||||
filteredTypes: Object.create(null)
|
||||
},
|
||||
gotoLocation: {
|
||||
multiple: 'peek'
|
||||
},
|
||||
foldingStrategy: 'auto',
|
||||
showFoldingControls: 'mouseover',
|
||||
find: {
|
||||
seedSearchStringFromSelection: true,
|
||||
autoFindInSelection: false,
|
||||
globalFindClipboard: false,
|
||||
addExtraSpaceOnTop: true
|
||||
},
|
||||
codeActionsOnSave: {},
|
||||
codeActionsOnSaveTimeout: 750
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -1565,6 +1204,9 @@ export class ChangedEditorOptions {
|
|||
this._values[id] = value;
|
||||
}
|
||||
}
|
||||
|
||||
//#region IEditorOption
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -1600,16 +1242,6 @@ export interface IEditorOption<K1 extends EditorOption, K2 extends keyof IEditor
|
|||
equals(a: T3, b: T3): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];
|
||||
|
||||
function registerEditorOption<K1 extends EditorOption, K2 extends keyof IEditorOptions, T2, T3>(option: IEditorOption<K1, K2, T2, T3>): IEditorOption<K1, K2, T2, T3> {
|
||||
editorOptionsRegistry[option.id] = option;
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -1724,6 +1356,7 @@ class EditorPassthroughOption<K1 extends EditorOption, K2 extends keyof IEditorO
|
|||
return value;
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region renderLineNumbers
|
||||
|
||||
|
@ -1819,6 +1452,84 @@ class EditorMinimap<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorM
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region hover
|
||||
|
||||
export interface InternalEditorHoverOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly delay: number;
|
||||
readonly sticky: boolean;
|
||||
}
|
||||
|
||||
class EditorHover<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorHoverOptions>> extends BaseEditorOption<K1, K2, InternalEditorHoverOptions> {
|
||||
public validate(input: IEditorHoverOptions | undefined): InternalEditorHoverOptions {
|
||||
if (typeof input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
return {
|
||||
enabled: _boolean(input.enabled, this.defaultValue.enabled),
|
||||
delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
|
||||
sticky: _boolean(input.sticky, this.defaultValue.sticky)
|
||||
};
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorHoverOptions): InternalEditorHoverOptions {
|
||||
return value;
|
||||
}
|
||||
public equals(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
|
||||
return (
|
||||
a.enabled === b.enabled
|
||||
&& a.delay === b.delay
|
||||
&& a.sticky === b.sticky
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region quickSuggestions
|
||||
|
||||
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;
|
||||
|
||||
class EditorQuickSuggestions<K1 extends EditorOption, K2 extends PossibleKeyName<boolean | IQuickSuggestionsOptions>> extends BaseEditorOption<K1, K2, ValidQuickSuggestionsOptions> {
|
||||
public readonly defaultValue: Readonly<Required<IQuickSuggestionsOptions>>;
|
||||
constructor(id: K1, name: K2, defaultValue: Readonly<Required<IQuickSuggestionsOptions>>) {
|
||||
super(id, name, defaultValue);
|
||||
}
|
||||
public validate(input: boolean | IQuickSuggestionsOptions | undefined): ValidQuickSuggestionsOptions {
|
||||
if (typeof input === 'boolean') {
|
||||
return input;
|
||||
}
|
||||
if (typeof input === 'object') {
|
||||
return {
|
||||
other: _boolean(input.other, this.defaultValue.other),
|
||||
comments: _boolean(input.comments, this.defaultValue.comments),
|
||||
strings: _boolean(input.strings, this.defaultValue.strings),
|
||||
};
|
||||
}
|
||||
return this.defaultValue;
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidQuickSuggestionsOptions): ValidQuickSuggestionsOptions {
|
||||
return value;
|
||||
}
|
||||
public equals(a: ValidQuickSuggestionsOptions, b: ValidQuickSuggestionsOptions): boolean {
|
||||
if (typeof a === 'boolean') {
|
||||
if (typeof b !== 'boolean') {
|
||||
return false;
|
||||
}
|
||||
return a === b;
|
||||
}
|
||||
if (typeof b === 'boolean') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
a.comments === b.comments
|
||||
&& a.other === b.other
|
||||
&& a.strings === b.strings
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region accessibilitySupport
|
||||
|
||||
class EditorAccessibilitySupportOption<K1 extends EditorOption, K2 extends PossibleKeyName<'auto' | 'off' | 'on'>> extends BaseEditorOption<K1, K2, 'auto' | 'off' | 'on', AccessibilitySupport> {
|
||||
|
@ -2029,6 +1740,161 @@ class EditorScrollbar<K1 extends EditorOption, K2 extends PossibleKeyName<IEdito
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region suggest
|
||||
|
||||
export type ValidSuggestOptions = Readonly<Required<ISuggestOptions>>;
|
||||
|
||||
export interface InternalSuggestOptions {
|
||||
readonly filterGraceful: boolean;
|
||||
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
|
||||
readonly snippetsPreventQuickSuggestions: boolean;
|
||||
readonly localityBonus: boolean;
|
||||
readonly shareSuggestSelections: boolean;
|
||||
readonly showIcons: boolean;
|
||||
readonly maxVisibleSuggestions: number;
|
||||
readonly filteredTypes: Record<string, boolean>;
|
||||
}
|
||||
|
||||
class EditorSuggest<K1 extends EditorOption, K2 extends PossibleKeyName<ISuggestOptions>> extends BaseEditorOption<K1, K2, ValidSuggestOptions, InternalSuggestOptions> {
|
||||
public validate(input: ISuggestOptions | undefined): ValidSuggestOptions {
|
||||
if (typeof input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
return {
|
||||
filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful),
|
||||
snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
|
||||
localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus),
|
||||
shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
|
||||
showIcons: _boolean(input.showIcons, this.defaultValue.showIcons),
|
||||
maxVisibleSuggestions: _clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15),
|
||||
filteredTypes: isObject(input.filteredTypes) ? input.filteredTypes : Object.create(null)
|
||||
};
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidSuggestOptions): InternalSuggestOptions {
|
||||
const snippetSuggestions = options.get(EditorOption.snippetSuggestions);
|
||||
return {
|
||||
filterGraceful: value.filterGraceful,
|
||||
snippets: snippetSuggestions,
|
||||
snippetsPreventQuickSuggestions: value.snippetsPreventQuickSuggestions,
|
||||
localityBonus: value.localityBonus,
|
||||
shareSuggestSelections: value.shareSuggestSelections,
|
||||
showIcons: value.showIcons,
|
||||
maxVisibleSuggestions: value.maxVisibleSuggestions,
|
||||
filteredTypes: value.filteredTypes,
|
||||
};
|
||||
}
|
||||
public equals(a: InternalSuggestOptions, b: InternalSuggestOptions): boolean {
|
||||
return (
|
||||
a.filterGraceful === b.filterGraceful
|
||||
&& a.snippets === b.snippets
|
||||
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
|
||||
&& a.localityBonus === b.localityBonus
|
||||
&& a.shareSuggestSelections === b.shareSuggestSelections
|
||||
&& a.showIcons === b.showIcons
|
||||
&& a.maxVisibleSuggestions === b.maxVisibleSuggestions
|
||||
&& objects.equals(a.filteredTypes, b.filteredTypes)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region parameterHints
|
||||
|
||||
export interface InternalParameterHintOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly cycle: boolean;
|
||||
}
|
||||
|
||||
class EditorParameterHints<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorParameterHintOptions>> extends BaseEditorOption<K1, K2, InternalParameterHintOptions> {
|
||||
public validate(input: IEditorParameterHintOptions | undefined): InternalParameterHintOptions {
|
||||
if (typeof input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
return {
|
||||
enabled: _boolean(input.enabled, this.defaultValue.enabled),
|
||||
cycle: _boolean(input.cycle, this.defaultValue.cycle)
|
||||
};
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalParameterHintOptions): InternalParameterHintOptions {
|
||||
return value;
|
||||
}
|
||||
public equals(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
|
||||
return (
|
||||
a.enabled === b.enabled
|
||||
&& a.cycle === b.cycle
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region find
|
||||
|
||||
export interface InternalEditorFindOptions {
|
||||
readonly seedSearchStringFromSelection: boolean;
|
||||
readonly autoFindInSelection: boolean;
|
||||
readonly addExtraSpaceOnTop: boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
readonly globalFindClipboard: boolean;
|
||||
}
|
||||
|
||||
class EditorFind<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorFindOptions>> extends BaseEditorOption<K1, K2, InternalEditorFindOptions> {
|
||||
public validate(input: IEditorFindOptions | undefined): InternalEditorFindOptions {
|
||||
if (typeof input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
return {
|
||||
seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection),
|
||||
autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection),
|
||||
globalFindClipboard: _boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
|
||||
addExtraSpaceOnTop: _boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop)
|
||||
};
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorFindOptions): InternalEditorFindOptions {
|
||||
return value;
|
||||
}
|
||||
public equals(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
|
||||
return (
|
||||
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
|
||||
&& a.autoFindInSelection === b.autoFindInSelection
|
||||
&& a.globalFindClipboard === b.globalFindClipboard
|
||||
&& a.addExtraSpaceOnTop === b.addExtraSpaceOnTop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region gotoLocation
|
||||
|
||||
export interface InternalGoToLocationOptions {
|
||||
readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
class EditorGoToLocation<K1 extends EditorOption, K2 extends PossibleKeyName<IGotoLocationOptions>> extends BaseEditorOption<K1, K2, InternalGoToLocationOptions> {
|
||||
public validate(input: IGotoLocationOptions | undefined): InternalGoToLocationOptions {
|
||||
if (typeof input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
return {
|
||||
multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto'])
|
||||
};
|
||||
}
|
||||
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalGoToLocationOptions): InternalGoToLocationOptions {
|
||||
return value;
|
||||
}
|
||||
public equals(a: InternalGoToLocationOptions, b: InternalGoToLocationOptions): boolean {
|
||||
return (
|
||||
a.multiple === b.multiple
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region layoutInfo
|
||||
|
||||
/**
|
||||
|
@ -2467,6 +2333,16 @@ function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'):
|
|||
return 'altKey';
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];
|
||||
|
||||
function registerEditorOption<K1 extends EditorOption, K2 extends keyof IEditorOptions, T2, T3>(option: IEditorOption<K1, K2, T2, T3>): IEditorOption<K1, K2, T2, T3> {
|
||||
editorOptionsRegistry[option.id] = option;
|
||||
return option;
|
||||
}
|
||||
|
||||
export const enum EditorOption {
|
||||
acceptSuggestionOnCommitCharacter,
|
||||
acceptSuggestionOnEnter,
|
||||
|
@ -2491,14 +2367,18 @@ export const enum EditorOption {
|
|||
emptySelectionClipboard,
|
||||
extraEditorClassName,
|
||||
fastScrollSensitivity,
|
||||
find,
|
||||
fixedOverflowWidgets,
|
||||
folding,
|
||||
foldingStrategy,
|
||||
fontLigatures,
|
||||
formatOnPaste,
|
||||
formatOnType,
|
||||
glyphMargin,
|
||||
gotoLocation,
|
||||
hideCursorInOverviewRuler,
|
||||
highlightActiveIndentGuide,
|
||||
hover,
|
||||
inDiffEditor,
|
||||
lightbulb,
|
||||
lineDecorationsWidth,
|
||||
|
@ -2515,6 +2395,8 @@ export const enum EditorOption {
|
|||
occurrencesHighlight,
|
||||
overviewRulerBorder,
|
||||
overviewRulerLanes,
|
||||
parameterHints,
|
||||
quickSuggestions,
|
||||
quickSuggestionsDelay,
|
||||
readOnly,
|
||||
renderControlCharacters,
|
||||
|
@ -2531,12 +2413,17 @@ export const enum EditorOption {
|
|||
selectionClipboard,
|
||||
selectionHighlight,
|
||||
selectOnLineNumbers,
|
||||
showFoldingControls,
|
||||
showUnused,
|
||||
snippetSuggestions,
|
||||
smoothScrolling,
|
||||
stopRenderingLineAfter,
|
||||
suggestFontSize,
|
||||
suggestLineHeight,
|
||||
suggestOnTriggerCharacters,
|
||||
suggestSelection,
|
||||
tabCompletion,
|
||||
useTabStops,
|
||||
wordBasedSuggestions,
|
||||
wordSeparators,
|
||||
wordWrap,
|
||||
wordWrapBreakAfterCharacters,
|
||||
|
@ -2550,6 +2437,7 @@ export const enum EditorOption {
|
|||
disableMonospaceOptimizations,
|
||||
editorClassName,
|
||||
tabFocusMode,
|
||||
suggest,
|
||||
layoutInfo,
|
||||
wrappingInfo,
|
||||
}
|
||||
|
@ -2578,14 +2466,29 @@ export const EditorOptions = {
|
|||
emptySelectionClipboard: registerEditorOption(new EditorEmptySelectionClipboard(EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true)),
|
||||
extraEditorClassName: registerEditorOption(new EditorStringOption(EditorOption.extraEditorClassName, 'extraEditorClassName', '')),
|
||||
fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))),
|
||||
find: registerEditorOption(new EditorFind(EditorOption.find, 'find', {
|
||||
seedSearchStringFromSelection: true,
|
||||
autoFindInSelection: false,
|
||||
globalFindClipboard: false,
|
||||
addExtraSpaceOnTop: true
|
||||
})),
|
||||
fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)),
|
||||
folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)),
|
||||
foldingStrategy: registerEditorOption(new EditorEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto', ['auto', 'indentation'], (x: 'auto' | 'indentation') => x)),
|
||||
fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)),
|
||||
formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)),
|
||||
formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)),
|
||||
glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)),
|
||||
gotoLocation: registerEditorOption(new EditorGoToLocation(EditorOption.gotoLocation, 'gotoLocation', {
|
||||
multiple: 'peek'
|
||||
})),
|
||||
hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)),
|
||||
highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)),
|
||||
hover: registerEditorOption(new EditorHover(EditorOption.hover, 'hover', {
|
||||
enabled: true,
|
||||
delay: 300,
|
||||
sticky: true
|
||||
})),
|
||||
inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)),
|
||||
lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', {
|
||||
enabled: true
|
||||
|
@ -2610,6 +2513,15 @@ export const EditorOptions = {
|
|||
occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)),
|
||||
overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)),
|
||||
overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)),
|
||||
parameterHints: registerEditorOption(new EditorParameterHints(EditorOption.parameterHints, 'parameterHints', {
|
||||
enabled: true,
|
||||
cycle: false
|
||||
})),
|
||||
quickSuggestions: registerEditorOption(new EditorQuickSuggestions(EditorOption.quickSuggestions, 'quickSuggestions', {
|
||||
other: true,
|
||||
comments: false,
|
||||
strings: false
|
||||
})),
|
||||
quickSuggestionsDelay: registerEditorOption(new EditorIntOption(EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay', 10, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
|
||||
readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)),
|
||||
renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)),
|
||||
|
@ -2638,12 +2550,17 @@ export const EditorOptions = {
|
|||
selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)),
|
||||
selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)),
|
||||
selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)),
|
||||
showFoldingControls: registerEditorOption(new EditorEnumOption(EditorOption.showFoldingControls, 'showFoldingControls', 'mouseover', ['always', 'mouseover'], (x: 'always' | 'mouseover') => x)),
|
||||
showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)),
|
||||
snippetSuggestions: registerEditorOption(new EditorEnumOption<EditorOption.snippetSuggestions, 'snippetSuggestions', 'top' | 'bottom' | 'inline' | 'none'>(EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline', ['top', 'bottom', 'inline', 'none'], x => x)),
|
||||
smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)),
|
||||
stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)),
|
||||
suggestFontSize: registerEditorOption(new EditorIntOption(EditorOption.suggestFontSize, 'suggestFontSize', 0, 0, 1000)),
|
||||
suggestLineHeight: registerEditorOption(new EditorIntOption(EditorOption.suggestLineHeight, 'suggestLineHeight', 0, 0, 1000)),
|
||||
suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)),
|
||||
suggestSelection: registerEditorOption(new EditorEnumOption(EditorOption.suggestSelection, 'suggestSelection', 'recentlyUsed', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'], (x: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix') => x)),
|
||||
tabCompletion: registerEditorOption(new EditorEnumOption(EditorOption.tabCompletion, 'tabCompletion', 'off', ['on', 'off', 'onlySnippets'], (x: 'on' | 'off' | 'onlySnippets') => x)),
|
||||
useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)),
|
||||
wordBasedSuggestions: registerEditorOption(new EditorBooleanOption(EditorOption.wordBasedSuggestions, 'wordBasedSuggestions', true)),
|
||||
wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)),
|
||||
wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], (x: 'off' | 'on' | 'wordWrapColumn' | 'bounded') => x)),
|
||||
wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')),
|
||||
|
@ -2653,11 +2570,20 @@ export const EditorOptions = {
|
|||
wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)),
|
||||
wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)),
|
||||
|
||||
// Leave these at the end!
|
||||
// Leave these at the end (because they have dependencies!)
|
||||
ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])),
|
||||
disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])),
|
||||
editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])),
|
||||
tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])),
|
||||
suggest: registerEditorOption(new EditorSuggest(EditorOption.suggest, 'suggest', {
|
||||
filterGraceful: true,
|
||||
snippetsPreventQuickSuggestions: true,
|
||||
localityBonus: false,
|
||||
shareSuggestSelections: false,
|
||||
showIcons: true,
|
||||
maxVisibleSuggestions: 12,
|
||||
filteredTypes: Object.create(null)
|
||||
}, [EditorOption.snippetSuggestions])),
|
||||
layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])),
|
||||
wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])),
|
||||
};
|
||||
|
|
|
@ -8,7 +8,6 @@ import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { SimpleWorkerClient, logOnceWebWorkerWarning, IWorkerClient } from 'vs/base/common/worker/simpleWorker';
|
||||
import { DefaultWorkerFactory } from 'vs/base/worker/defaultWorkerFactory';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
|
@ -146,7 +145,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
|
|||
}
|
||||
|
||||
provideCompletionItems(model: ITextModel, position: Position): Promise<modes.CompletionList | null> | undefined {
|
||||
const { wordBasedSuggestions } = this._configurationService.getValue<IEditorOptions>(model.uri, position, 'editor');
|
||||
const { wordBasedSuggestions } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean }>(model.uri, position, 'editor');
|
||||
if (!wordBasedSuggestions) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -463,66 +463,78 @@ export enum EditorOption {
|
|||
emptySelectionClipboard = 20,
|
||||
extraEditorClassName = 21,
|
||||
fastScrollSensitivity = 22,
|
||||
fixedOverflowWidgets = 23,
|
||||
folding = 24,
|
||||
fontLigatures = 25,
|
||||
formatOnPaste = 26,
|
||||
formatOnType = 27,
|
||||
glyphMargin = 28,
|
||||
hideCursorInOverviewRuler = 29,
|
||||
highlightActiveIndentGuide = 30,
|
||||
inDiffEditor = 31,
|
||||
lightbulb = 32,
|
||||
lineDecorationsWidth = 33,
|
||||
lineNumbers = 34,
|
||||
lineNumbersMinChars = 35,
|
||||
links = 36,
|
||||
matchBrackets = 37,
|
||||
minimap = 38,
|
||||
mouseStyle = 39,
|
||||
mouseWheelScrollSensitivity = 40,
|
||||
mouseWheelZoom = 41,
|
||||
multiCursorMergeOverlapping = 42,
|
||||
multiCursorModifier = 43,
|
||||
occurrencesHighlight = 44,
|
||||
overviewRulerBorder = 45,
|
||||
overviewRulerLanes = 46,
|
||||
quickSuggestionsDelay = 47,
|
||||
readOnly = 48,
|
||||
renderControlCharacters = 49,
|
||||
renderIndentGuides = 50,
|
||||
renderFinalNewline = 51,
|
||||
renderLineHighlight = 52,
|
||||
renderWhitespace = 53,
|
||||
revealHorizontalRightPadding = 54,
|
||||
roundedSelection = 55,
|
||||
rulers = 56,
|
||||
scrollbar = 57,
|
||||
scrollBeyondLastColumn = 58,
|
||||
scrollBeyondLastLine = 59,
|
||||
selectionClipboard = 60,
|
||||
selectionHighlight = 61,
|
||||
selectOnLineNumbers = 62,
|
||||
showUnused = 63,
|
||||
smoothScrolling = 64,
|
||||
stopRenderingLineAfter = 65,
|
||||
suggestOnTriggerCharacters = 66,
|
||||
useTabStops = 67,
|
||||
wordBasedSuggestions = 68,
|
||||
wordSeparators = 69,
|
||||
wordWrap = 70,
|
||||
wordWrapBreakAfterCharacters = 71,
|
||||
wordWrapBreakBeforeCharacters = 72,
|
||||
wordWrapBreakObtrusiveCharacters = 73,
|
||||
wordWrapColumn = 74,
|
||||
wordWrapMinified = 75,
|
||||
wrappingIndent = 76,
|
||||
ariaLabel = 77,
|
||||
disableMonospaceOptimizations = 78,
|
||||
editorClassName = 79,
|
||||
tabFocusMode = 80,
|
||||
layoutInfo = 81,
|
||||
wrappingInfo = 82
|
||||
find = 23,
|
||||
fixedOverflowWidgets = 24,
|
||||
folding = 25,
|
||||
foldingStrategy = 26,
|
||||
fontLigatures = 27,
|
||||
formatOnPaste = 28,
|
||||
formatOnType = 29,
|
||||
glyphMargin = 30,
|
||||
gotoLocation = 31,
|
||||
hideCursorInOverviewRuler = 32,
|
||||
highlightActiveIndentGuide = 33,
|
||||
hover = 34,
|
||||
inDiffEditor = 35,
|
||||
lightbulb = 36,
|
||||
lineDecorationsWidth = 37,
|
||||
lineNumbers = 38,
|
||||
lineNumbersMinChars = 39,
|
||||
links = 40,
|
||||
matchBrackets = 41,
|
||||
minimap = 42,
|
||||
mouseStyle = 43,
|
||||
mouseWheelScrollSensitivity = 44,
|
||||
mouseWheelZoom = 45,
|
||||
multiCursorMergeOverlapping = 46,
|
||||
multiCursorModifier = 47,
|
||||
occurrencesHighlight = 48,
|
||||
overviewRulerBorder = 49,
|
||||
overviewRulerLanes = 50,
|
||||
parameterHints = 51,
|
||||
quickSuggestions = 52,
|
||||
quickSuggestionsDelay = 53,
|
||||
readOnly = 54,
|
||||
renderControlCharacters = 55,
|
||||
renderIndentGuides = 56,
|
||||
renderFinalNewline = 57,
|
||||
renderLineHighlight = 58,
|
||||
renderWhitespace = 59,
|
||||
revealHorizontalRightPadding = 60,
|
||||
roundedSelection = 61,
|
||||
rulers = 62,
|
||||
scrollbar = 63,
|
||||
scrollBeyondLastColumn = 64,
|
||||
scrollBeyondLastLine = 65,
|
||||
selectionClipboard = 66,
|
||||
selectionHighlight = 67,
|
||||
selectOnLineNumbers = 68,
|
||||
showFoldingControls = 69,
|
||||
showUnused = 70,
|
||||
snippetSuggestions = 71,
|
||||
smoothScrolling = 72,
|
||||
stopRenderingLineAfter = 73,
|
||||
suggestFontSize = 74,
|
||||
suggestLineHeight = 75,
|
||||
suggestOnTriggerCharacters = 76,
|
||||
suggestSelection = 77,
|
||||
tabCompletion = 78,
|
||||
useTabStops = 79,
|
||||
wordSeparators = 80,
|
||||
wordWrap = 81,
|
||||
wordWrapBreakAfterCharacters = 82,
|
||||
wordWrapBreakBeforeCharacters = 83,
|
||||
wordWrapBreakObtrusiveCharacters = 84,
|
||||
wordWrapColumn = 85,
|
||||
wordWrapMinified = 86,
|
||||
wrappingIndent = 87,
|
||||
ariaLabel = 88,
|
||||
disableMonospaceOptimizations = 89,
|
||||
editorClassName = 90,
|
||||
tabFocusMode = 91,
|
||||
suggest = 92,
|
||||
layoutInfo = 93,
|
||||
wrappingInfo = 94
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
|||
}));
|
||||
this._register(this._editor.onDidChangeConfiguration(e => {
|
||||
// hide when told to do so
|
||||
if (e.contribInfo && !this._editor.getOption(EditorOption.lightbulb).enabled) {
|
||||
if (e.hasChanged(EditorOption.lightbulb) && !this._editor.getOption(EditorOption.lightbulb).enabled) {
|
||||
this.hide();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -148,7 +148,7 @@ export class ContextMenuController implements IEditorContribution {
|
|||
}
|
||||
|
||||
// Disable hover
|
||||
const oldHoverSetting = this._editor.getConfiguration().contribInfo.hover;
|
||||
const oldHoverSetting = this._editor.getOption(EditorOption.hover);
|
||||
this._editor.updateOptions({
|
||||
hover: {
|
||||
enabled: false
|
||||
|
|
|
@ -121,7 +121,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
|||
if (shouldRestartFind) {
|
||||
this._start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: false && this._editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: false && this._editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -353,7 +353,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
|||
}
|
||||
|
||||
public getGlobalBufferTerm(): string {
|
||||
if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard
|
||||
if (this._editor.getOption(EditorOption.find).globalFindClipboard
|
||||
&& this._clipboardService
|
||||
&& this._editor.hasModel()
|
||||
&& !this._editor.getModel().isTooLargeForSyncing()
|
||||
|
@ -364,7 +364,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
|||
}
|
||||
|
||||
public setGlobalBufferTerm(text: string) {
|
||||
if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard
|
||||
if (this._editor.getOption(EditorOption.find).globalFindClipboard
|
||||
&& this._clipboardService
|
||||
&& this._editor.hasModel()
|
||||
&& !this._editor.getModel().isTooLargeForSyncing()
|
||||
|
@ -399,7 +399,7 @@ export class FindController extends CommonFindController implements IFindControl
|
|||
this._createFindWidget();
|
||||
}
|
||||
|
||||
if (!this._widget!.getPosition() && this._editor.getConfiguration().contribInfo.find.autoFindInSelection) {
|
||||
if (!this._widget!.getPosition() && this._editor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
// not visible yet so we need to set search scope if `editor.find.autoFindInSelection` is `true`
|
||||
opts.updateSearchScope = true;
|
||||
}
|
||||
|
@ -457,8 +457,8 @@ export class StartFindAction extends EditorAction {
|
|||
if (controller) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.globalFindClipboard,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).globalFindClipboard,
|
||||
shouldFocus: FindStartFocusAction.FocusFindInput,
|
||||
shouldAnimate: true,
|
||||
updateSearchScope: false
|
||||
|
@ -508,7 +508,7 @@ export abstract class MatchFindAction extends EditorAction {
|
|||
if (controller && !this._run(controller)) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: true,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
|
@ -620,7 +620,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
|
|||
if (!this._run(controller)) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
|
@ -709,7 +709,7 @@ export class StartFindReplaceAction extends EditorAction {
|
|||
// we only seed search string from selection when the current selection is single line and not empty,
|
||||
// + the find input is not focused
|
||||
let seedSearchStringFromSelection = !currentSelection.isEmpty()
|
||||
&& currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection
|
||||
&& currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getOption(EditorOption.find).seedSearchStringFromSelection
|
||||
&& !findInputFocused;
|
||||
/*
|
||||
* if the existing search string in find widget is empty and we don't seed search string from selection, it means the Find Input is still empty, so we should focus the Find Input instead of Replace Input.
|
||||
|
@ -726,7 +726,7 @@ export class StartFindReplaceAction extends EditorAction {
|
|||
controller.start({
|
||||
forceRevealReplace: true,
|
||||
seedSearchStringFromSelection: seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
shouldFocus: shouldFocus,
|
||||
shouldAnimate: true,
|
||||
updateSearchScope: false
|
||||
|
|
|
@ -192,8 +192,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
this.updateAccessibilitySupport();
|
||||
}
|
||||
|
||||
if (e.contribInfo) {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
if (e.hasChanged(EditorOption.find)) {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
if (addExtraSpaceOnTop && !this._viewZone) {
|
||||
this._viewZone = new FindWidgetViewZone(0);
|
||||
this._showViewZone();
|
||||
|
@ -239,7 +239,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
}));
|
||||
|
||||
this._codeEditor.addOverlayWidget(this);
|
||||
if (this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop) {
|
||||
if (this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop) {
|
||||
this._viewZone = new FindWidgetViewZone(0); // Put it before the first line then users can scroll beyond the first line.
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
|
||||
const selection = this._codeEditor.getSelection();
|
||||
const isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
|
||||
if (isSelection && this._codeEditor.getConfiguration().contribInfo.find.autoFindInSelection) {
|
||||
if (isSelection && this._codeEditor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
this._toggleSelectionFind.checked = true;
|
||||
} else {
|
||||
this._toggleSelectionFind.checked = false;
|
||||
|
@ -488,7 +488,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
this._codeEditor.layoutOverlayWidget(this);
|
||||
|
||||
let adjustEditorScrollTop = true;
|
||||
if (this._codeEditor.getConfiguration().contribInfo.find.seedSearchStringFromSelection && selection) {
|
||||
if (this._codeEditor.getOption(EditorOption.find).seedSearchStringFromSelection && selection) {
|
||||
const domNode = this._codeEditor.getDomNode();
|
||||
if (domNode) {
|
||||
const editorCoords = dom.getDomNodePagePosition(domNode);
|
||||
|
@ -535,7 +535,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
}
|
||||
|
||||
private _layoutViewZone() {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
|
||||
if (!addExtraSpaceOnTop) {
|
||||
this._removeViewZone();
|
||||
|
@ -563,7 +563,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
|||
return;
|
||||
}
|
||||
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
|
||||
if (!addExtraSpaceOnTop) {
|
||||
return;
|
||||
|
|
|
@ -89,8 +89,8 @@ export class FoldingController extends Disposable implements IEditorContribution
|
|||
this.editor = editor;
|
||||
const options = this.editor.getOptions();
|
||||
this._isEnabled = options.get(EditorOption.folding);
|
||||
this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover';
|
||||
this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation';
|
||||
this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
|
||||
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
|
||||
|
||||
this.foldingModel = null;
|
||||
this.hiddenRangeModel = null;
|
||||
|
@ -110,7 +110,7 @@ export class FoldingController extends Disposable implements IEditorContribution
|
|||
this._register(this.editor.onDidChangeModel(() => this.onModelChanged()));
|
||||
|
||||
this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.contribInfo || e.hasChanged(EditorOption.folding)) {
|
||||
if (e.hasChanged(EditorOption.folding) || e.hasChanged(EditorOption.showFoldingControls) || e.hasChanged(EditorOption.foldingStrategy)) {
|
||||
let oldIsEnabled = this._isEnabled;
|
||||
const options = this.editor.getOptions();
|
||||
this._isEnabled = options.get(EditorOption.folding);
|
||||
|
@ -119,13 +119,13 @@ export class FoldingController extends Disposable implements IEditorContribution
|
|||
this.onModelChanged();
|
||||
}
|
||||
let oldShowFoldingControls = this._autoHideFoldingControls;
|
||||
this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover';
|
||||
this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
|
||||
if (oldShowFoldingControls !== this._autoHideFoldingControls) {
|
||||
this.foldingDecorationProvider.autoHideFoldingControls = this._autoHideFoldingControls;
|
||||
this.onModelContentChanged();
|
||||
}
|
||||
let oldUseFoldingProviders = this._useFoldingProviders;
|
||||
this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation';
|
||||
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
|
||||
if (oldUseFoldingProviders !== this._useFoldingProviders) {
|
||||
this.onFoldingStrategyChanged();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefiniti
|
|||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState';
|
||||
import { ISymbolNavigationService } from 'vs/editor/contrib/goToDefinition/goToDefinitionResultsNavigation';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class DefinitionActionConfig {
|
||||
|
||||
|
@ -137,7 +138,7 @@ export class DefinitionAction extends EditorAction {
|
|||
const msg = model.getAriaMessage();
|
||||
alert(msg);
|
||||
|
||||
const { gotoLocation } = editor.getConfiguration().contribInfo;
|
||||
const gotoLocation = editor.getOption(EditorOption.gotoLocation);
|
||||
if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) {
|
||||
this._openInPeek(editorService, editor, model);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ export class ModesHoverController implements IEditorContribution {
|
|||
this._hookEvents();
|
||||
|
||||
this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.contribInfo) {
|
||||
if (e.hasChanged(EditorOption.hover)) {
|
||||
this._hideWidgets();
|
||||
this._unhookEvents();
|
||||
this._hookEvents();
|
||||
|
@ -86,7 +86,7 @@ export class ModesHoverController implements IEditorContribution {
|
|||
private _hookEvents(): void {
|
||||
const hideWidgetsEventHandler = () => this._hideWidgets();
|
||||
|
||||
const hoverOpts = this._editor.getConfiguration().contribInfo.hover;
|
||||
const hoverOpts = this._editor.getOption(EditorOption.hover);
|
||||
this._isHoverEnabled = hoverOpts.enabled;
|
||||
this._isHoverSticky = hoverOpts.sticky;
|
||||
if (this._isHoverEnabled) {
|
||||
|
@ -147,7 +147,6 @@ export class ModesHoverController implements IEditorContribution {
|
|||
}
|
||||
|
||||
private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void {
|
||||
// const this._editor.getConfiguration().contribInfo.hover.sticky;
|
||||
let targetType = mouseEvent.target.type;
|
||||
|
||||
if (this._isMouseDown && this._hoverClicked && this.contentWidget.isColorPickerVisible()) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import { QuickFixAction, QuickFixController } from 'vs/editor/contrib/codeAction
|
|||
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
|
@ -222,7 +223,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
|||
result => this._withResult(result, true),
|
||||
null,
|
||||
result => this._withResult(result, false),
|
||||
this._editor.getConfiguration().contribInfo.hover.delay
|
||||
this._editor.getOption(EditorOption.hover).delay
|
||||
);
|
||||
|
||||
this._register(dom.addStandardDisposableListener(this.getDomNode(), dom.EventType.FOCUS, () => {
|
||||
|
@ -234,7 +235,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
|||
dom.removeClass(this.getDomNode(), 'colorpicker-hover');
|
||||
}));
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
this._hoverOperation.setHoverTime(this._editor.getConfiguration().contribInfo.hover.delay);
|
||||
this._hoverOperation.setHoverTime(this._editor.getOption(EditorOption.hover).delay);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursor
|
|||
import { CharacterSet } from 'vs/editor/common/core/characterClassifier';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { provideSignatureHelp } from 'vs/editor/contrib/parameterHints/provideSignatureHelp';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export interface TriggerContext {
|
||||
readonly triggerKind: modes.SignatureHelpTriggerKind;
|
||||
|
@ -125,7 +126,7 @@ export class ParameterHintsModel extends Disposable {
|
|||
const length = this.state.hints.signatures.length;
|
||||
const activeSignature = this.state.hints.activeSignature;
|
||||
const last = (activeSignature % length) === (length - 1);
|
||||
const cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle;
|
||||
const cycle = this.editor.getOption(EditorOption.parameterHints).cycle;
|
||||
|
||||
// If there is only one signature, or we're on last signature of list
|
||||
if ((length < 2 || last) && !cycle) {
|
||||
|
@ -144,7 +145,7 @@ export class ParameterHintsModel extends Disposable {
|
|||
const length = this.state.hints.signatures.length;
|
||||
const activeSignature = this.state.hints.activeSignature;
|
||||
const first = activeSignature === 0;
|
||||
const cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle;
|
||||
const cycle = this.editor.getOption(EditorOption.parameterHints).cycle;
|
||||
|
||||
// If there is only one signature, or we're on first signature of list
|
||||
if ((length < 2 || first) && !cycle) {
|
||||
|
@ -271,7 +272,7 @@ export class ParameterHintsModel extends Disposable {
|
|||
}
|
||||
|
||||
private onEditorConfigurationChange(): void {
|
||||
this.triggerOnType = this.editor.getConfiguration().contribInfo.parameterHints.enabled;
|
||||
this.triggerOnType = this.editor.getOption(EditorOption.parameterHints).enabled;
|
||||
|
||||
if (!this.triggerOnType) {
|
||||
this.cancel();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { fuzzyScore, fuzzyScoreGracefulAggressive, FuzzyScorer, FuzzyScore, anyScore } from 'vs/base/common/filters';
|
||||
import { CompletionItemProvider, CompletionItemKind } from 'vs/editor/common/modes';
|
||||
import { CompletionItem } from './suggest';
|
||||
import { InternalSuggestOptions, EDITOR_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { InternalSuggestOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { compareIgnoreCase } from 'vs/base/common/strings';
|
||||
|
@ -60,7 +60,7 @@ export class CompletionModel {
|
|||
column: number,
|
||||
lineContext: LineContext,
|
||||
wordDistance: WordDistance,
|
||||
options: InternalSuggestOptions = EDITOR_DEFAULTS.contribInfo.suggest
|
||||
options: InternalSuggestOptions
|
||||
) {
|
||||
this._items = items;
|
||||
this._column = column;
|
||||
|
|
|
@ -278,7 +278,7 @@ export class SuggestModel implements IDisposable {
|
|||
|
||||
if (this._state === State.Idle) {
|
||||
|
||||
if (this._editor.getConfiguration().contribInfo.quickSuggestions === false) {
|
||||
if (this._editor.getOption(EditorOption.quickSuggestions) === false) {
|
||||
// not enabled
|
||||
return;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ export class SuggestModel implements IDisposable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this._editor.getConfiguration().contribInfo.suggest.snippetsPreventQuickSuggestions && SnippetController2.get(this._editor).isInSnippet()) {
|
||||
if (this._editor.getOption(EditorOption.suggest).snippetsPreventQuickSuggestions && SnippetController2.get(this._editor).isInSnippet()) {
|
||||
// no quick suggestion when in snippet mode
|
||||
return;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ export class SuggestModel implements IDisposable {
|
|||
const model = this._editor.getModel();
|
||||
const pos = this._editor.getPosition();
|
||||
// validate enabled now
|
||||
const { quickSuggestions } = this._editor.getConfiguration().contribInfo;
|
||||
const quickSuggestions = this._editor.getOption(EditorOption.quickSuggestions);
|
||||
if (quickSuggestions === false) {
|
||||
return;
|
||||
} else if (quickSuggestions === true) {
|
||||
|
@ -388,10 +388,10 @@ export class SuggestModel implements IDisposable {
|
|||
this._requestToken = new CancellationTokenSource();
|
||||
|
||||
// kind filter and snippet sort rules
|
||||
const { contribInfo } = this._editor.getConfiguration();
|
||||
const suggestOptions = this._editor.getOption(EditorOption.suggest);
|
||||
let itemKindFilter = new Set<CompletionItemKind>();
|
||||
let snippetSortOrder = SnippetSortOrder.Inline;
|
||||
switch (contribInfo.suggest.snippets) {
|
||||
switch (suggestOptions.snippets) {
|
||||
case 'top':
|
||||
snippetSortOrder = SnippetSortOrder.Top;
|
||||
break;
|
||||
|
@ -408,9 +408,9 @@ export class SuggestModel implements IDisposable {
|
|||
}
|
||||
|
||||
// kind filter
|
||||
for (const key in contribInfo.suggest.filteredTypes) {
|
||||
for (const key in suggestOptions.filteredTypes) {
|
||||
const kind = completionKindFromString(key, true);
|
||||
if (typeof kind !== 'undefined' && contribInfo.suggest.filteredTypes[key] === false) {
|
||||
if (typeof kind !== 'undefined' && suggestOptions.filteredTypes[key] === false) {
|
||||
itemKindFilter.add(kind);
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ export class SuggestModel implements IDisposable {
|
|||
characterCountDelta: ctx.column - this._context!.column
|
||||
},
|
||||
wordDistance,
|
||||
this._editor.getConfiguration().contribInfo.suggest
|
||||
this._editor.getOption(EditorOption.suggest)
|
||||
);
|
||||
|
||||
// store containers so that they can be disposed later
|
||||
|
|
|
@ -16,7 +16,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget';
|
|||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { Context as SuggestContext, CompletionItem } from './suggest';
|
||||
import { CompletionModel } from './completionModel';
|
||||
|
@ -125,9 +125,10 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
|
|||
|
||||
const configureFont = () => {
|
||||
const configuration = this.editor.getConfiguration();
|
||||
const options = this.editor.getOptions();
|
||||
const fontFamily = configuration.fontInfo.fontFamily;
|
||||
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
|
||||
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
|
||||
const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize;
|
||||
const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight;
|
||||
const fontWeight = configuration.fontInfo.fontWeight;
|
||||
const fontSizePx = `${fontSize}px`;
|
||||
const lineHeightPx = `${lineHeight}px`;
|
||||
|
@ -145,7 +146,7 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
|
|||
configureFont();
|
||||
|
||||
data.disposables.add(Event.chain<IConfigurationChangedEvent>(this.editor.onDidChangeConfiguration.bind(this.editor))
|
||||
.filter(e => e.fontInfo || e.contribInfo)
|
||||
.filter(e => e.fontInfo || e.hasChanged(EditorOption.suggestFontSize) || e.hasChanged(EditorOption.suggestLineHeight))
|
||||
.on(configureFont, null));
|
||||
|
||||
return data;
|
||||
|
@ -390,9 +391,10 @@ class SuggestionDetails {
|
|||
|
||||
private configureFont() {
|
||||
const configuration = this.editor.getConfiguration();
|
||||
const options = this.editor.getOptions();
|
||||
const fontFamily = configuration.fontInfo.fontFamily;
|
||||
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
|
||||
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
|
||||
const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize;
|
||||
const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight;
|
||||
const fontWeight = configuration.fontInfo.fontWeight;
|
||||
const fontSizePx = `${fontSize}px`;
|
||||
const lineHeightPx = `${lineHeight}px`;
|
||||
|
@ -500,7 +502,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
|
|||
this.listElement = append(this.element, $('.tree'));
|
||||
this.details = instantiationService.createInstance(SuggestionDetails, this.element, this, this.editor, markdownRenderer, triggerKeybindingLabel);
|
||||
|
||||
const applyIconStyle = () => toggleClass(this.element, 'no-icons', !this.editor.getConfiguration().contribInfo.suggest.showIcons);
|
||||
const applyIconStyle = () => toggleClass(this.element, 'no-icons', !this.editor.getOption(EditorOption.suggest).showIcons);
|
||||
applyIconStyle();
|
||||
|
||||
let renderer = instantiationService.createInstance(Renderer, this, this.editor, triggerKeybindingLabel);
|
||||
|
@ -521,7 +523,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
|
|||
this.toDispose.add(this.list.onSelectionChange(e => this.onListSelection(e)));
|
||||
this.toDispose.add(this.list.onFocusChange(e => this.onListFocus(e)));
|
||||
this.toDispose.add(this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged()));
|
||||
this.toDispose.add(this.editor.onDidChangeConfiguration(e => e.contribInfo && applyIconStyle()));
|
||||
this.toDispose.add(this.editor.onDidChangeConfiguration(e => e.hasChanged(EditorOption.suggest) && applyIconStyle()));
|
||||
|
||||
|
||||
this.suggestWidgetVisible = SuggestContext.Visible.bindTo(contextKeyService);
|
||||
|
@ -1051,7 +1053,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
|
|||
height = this.unfocusedHeight;
|
||||
} else {
|
||||
const suggestionCount = this.list.contentHeight / this.unfocusedHeight;
|
||||
const { maxVisibleSuggestions } = this.editor.getConfiguration().contribInfo.suggest;
|
||||
const { maxVisibleSuggestions } = this.editor.getOption(EditorOption.suggest);
|
||||
height = Math.min(suggestionCount, maxVisibleSuggestions) * this.unfocusedHeight;
|
||||
}
|
||||
|
||||
|
@ -1132,12 +1134,13 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
|
|||
// Heights
|
||||
|
||||
private get maxWidgetHeight(): number {
|
||||
return this.unfocusedHeight * this.editor.getConfiguration().contribInfo.suggest.maxVisibleSuggestions;
|
||||
return this.unfocusedHeight * this.editor.getOption(EditorOption.suggest).maxVisibleSuggestions;
|
||||
}
|
||||
|
||||
private get unfocusedHeight(): number {
|
||||
const configuration = this.editor.getConfiguration();
|
||||
return configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
|
||||
const options = this.editor.getOptions();
|
||||
return options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight;
|
||||
}
|
||||
|
||||
// IDelegate
|
||||
|
|
|
@ -8,6 +8,7 @@ import * as modes from 'vs/editor/common/modes';
|
|||
import { CompletionModel } from 'vs/editor/contrib/suggest/completionModel';
|
||||
import { CompletionItem, getSuggestionComparator, SnippetSortOrder } from 'vs/editor/contrib/suggest/suggest';
|
||||
import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance';
|
||||
import { EditorOptions, InternalSuggestOptions } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export function createSuggestItem(label: string, overwriteBefore: number, kind = modes.CompletionItemKind.Property, incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }, sortText?: string, filterText?: string): CompletionItem {
|
||||
const suggestion: modes.CompletionItem = {
|
||||
|
@ -30,6 +31,16 @@ export function createSuggestItem(label: string, overwriteBefore: number, kind =
|
|||
|
||||
return new CompletionItem(position, suggestion, container, provider, undefined!);
|
||||
}
|
||||
const defaultInternalSuggestOptions: InternalSuggestOptions = {
|
||||
filterGraceful: EditorOptions.suggest.defaultValue.filterGraceful,
|
||||
snippets: EditorOptions.snippetSuggestions.defaultValue,
|
||||
snippetsPreventQuickSuggestions: EditorOptions.suggest.defaultValue.snippetsPreventQuickSuggestions,
|
||||
localityBonus: EditorOptions.suggest.defaultValue.localityBonus,
|
||||
shareSuggestSelections: EditorOptions.suggest.defaultValue.shareSuggestSelections,
|
||||
showIcons: EditorOptions.suggest.defaultValue.showIcons,
|
||||
maxVisibleSuggestions: EditorOptions.suggest.defaultValue.maxVisibleSuggestions,
|
||||
filteredTypes: EditorOptions.suggest.defaultValue.filteredTypes,
|
||||
};
|
||||
suite('CompletionModel', function () {
|
||||
|
||||
|
||||
|
@ -44,7 +55,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: 'foo',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
});
|
||||
|
||||
test('filtering - cached', function () {
|
||||
|
@ -75,7 +86,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: 'foo',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
assert.equal(incompleteModel.incomplete.size, 1);
|
||||
});
|
||||
|
||||
|
@ -84,7 +95,7 @@ suite('CompletionModel', function () {
|
|||
const completeItem = createSuggestItem('foobar', 1, undefined, false, { lineNumber: 1, column: 2 });
|
||||
const incompleteItem = createSuggestItem('foofoo', 1, undefined, true, { lineNumber: 1, column: 2 });
|
||||
|
||||
const model = new CompletionModel([completeItem, incompleteItem], 2, { leadingLineContent: 'f', characterCountDelta: 0 }, WordDistance.None);
|
||||
const model = new CompletionModel([completeItem, incompleteItem], 2, { leadingLineContent: 'f', characterCountDelta: 0 }, WordDistance.None, defaultInternalSuggestOptions);
|
||||
assert.equal(model.incomplete.size, 1);
|
||||
assert.equal(model.items.length, 2);
|
||||
|
||||
|
@ -113,7 +124,7 @@ suite('CompletionModel', function () {
|
|||
completeItem4,
|
||||
completeItem5,
|
||||
incompleteItem1,
|
||||
], 2, { leadingLineContent: 'f', characterCountDelta: 0 }, WordDistance.None
|
||||
], 2, { leadingLineContent: 'f', characterCountDelta: 0 }, WordDistance.None, defaultInternalSuggestOptions
|
||||
);
|
||||
assert.equal(model.incomplete.size, 1);
|
||||
assert.equal(model.items.length, 6);
|
||||
|
@ -137,7 +148,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: ' <',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
assert.equal(model.items.length, 4);
|
||||
|
||||
|
@ -238,7 +249,7 @@ suite('CompletionModel', function () {
|
|||
model = new CompletionModel([item1, item2], 1, {
|
||||
leadingLineContent: 'M',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
assert.equal(model.items.length, 2);
|
||||
|
||||
|
@ -258,7 +269,7 @@ suite('CompletionModel', function () {
|
|||
model = new CompletionModel(items, 3, {
|
||||
leadingLineContent: ' ',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
assert.equal(model.items.length, 2);
|
||||
|
||||
|
@ -277,7 +288,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: '',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
assert.equal(model.items.length, 5);
|
||||
|
||||
|
@ -304,7 +315,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: '',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
// query gets longer, narrow down the narrow-down'ed-set from before
|
||||
model.lineContext = { leadingLineContent: 'rlut', characterCountDelta: 4 };
|
||||
|
@ -326,7 +337,7 @@ suite('CompletionModel', function () {
|
|||
], 1, {
|
||||
leadingLineContent: '',
|
||||
characterCountDelta: 0
|
||||
}, WordDistance.None);
|
||||
}, WordDistance.None, defaultInternalSuggestOptions);
|
||||
|
||||
model.lineContext = { leadingLineContent: 'form', characterCountDelta: 4 };
|
||||
assert.equal(model.items.length, 5);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class WordContextKey extends Disposable {
|
||||
|
||||
|
@ -22,7 +23,7 @@ export class WordContextKey extends Disposable {
|
|||
) {
|
||||
super();
|
||||
this._ckAtEnd = WordContextKey.AtEnd.bindTo(contextKeyService);
|
||||
this._register(this._editor.onDidChangeConfiguration(e => e.contribInfo && this._update()));
|
||||
this._register(this._editor.onDidChangeConfiguration(e => e.hasChanged(EditorOption.tabCompletion) && this._update()));
|
||||
this._update();
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,7 @@ export class WordContextKey extends Disposable {
|
|||
|
||||
private _update(): void {
|
||||
// only update this when tab completions are enabled
|
||||
const enabled = this._editor.getConfiguration().contribInfo.tabCompletion === 'on';
|
||||
const enabled = this._editor.getOption(EditorOption.tabCompletion) === 'on';
|
||||
if (this._enabled === enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { IPosition } from 'vs/editor/common/core/position';
|
|||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CompletionItem, CompletionItemKind } from 'vs/editor/common/modes';
|
||||
import { BracketSelectionRangeProvider } from 'vs/editor/contrib/smartSelect/bracketSelections';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export abstract class WordDistance {
|
||||
|
||||
|
@ -19,7 +20,7 @@ export abstract class WordDistance {
|
|||
|
||||
static create(service: IEditorWorkerService, editor: ICodeEditor): Promise<WordDistance> {
|
||||
|
||||
if (!editor.getConfiguration().contribInfo.suggest.localityBonus) {
|
||||
if (!editor.getOption(EditorOption.suggest).localityBonus) {
|
||||
return Promise.resolve(WordDistance.None);
|
||||
}
|
||||
|
||||
|
|
|
@ -186,8 +186,8 @@ suite('Common Editor Config', () => {
|
|||
});
|
||||
let config = new TestConfiguration({ hover: hoverOptions });
|
||||
|
||||
assert.equal(config.editor.contribInfo.hover.enabled, true);
|
||||
assert.equal(config.options.get(EditorOption.hover).enabled, true);
|
||||
config.updateOptions({ hover: { enabled: false } });
|
||||
assert.equal(config.editor.contribInfo.hover.enabled, false);
|
||||
assert.equal(config.options.get(EditorOption.hover).enabled, false);
|
||||
});
|
||||
});
|
||||
|
|
264
src/vs/monaco.d.ts
vendored
264
src/vs/monaco.d.ts
vendored
|
@ -2611,7 +2611,7 @@ declare namespace monaco.editor {
|
|||
/**
|
||||
* Max suggestions to show in suggestions. Defaults to 12.
|
||||
*/
|
||||
maxVisibleSuggestions?: boolean;
|
||||
maxVisibleSuggestions?: number;
|
||||
/**
|
||||
* Names of suggestion types to filter.
|
||||
*/
|
||||
|
@ -2625,11 +2625,10 @@ declare namespace monaco.editor {
|
|||
multiple?: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration map for codeActionsOnSave
|
||||
*/
|
||||
export interface ICodeActionsOnSaveOptions {
|
||||
[kind: string]: boolean;
|
||||
export interface IQuickSuggestionsOptions {
|
||||
other: boolean;
|
||||
comments: boolean;
|
||||
strings: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2921,11 +2920,7 @@ declare namespace monaco.editor {
|
|||
* Enable quick suggestions (shadow suggestions)
|
||||
* Defaults to true.
|
||||
*/
|
||||
quickSuggestions?: boolean | {
|
||||
other: boolean;
|
||||
comments: boolean;
|
||||
strings: boolean;
|
||||
};
|
||||
quickSuggestions?: boolean | IQuickSuggestionsOptions;
|
||||
/**
|
||||
* Quick suggestions show delay (in ms)
|
||||
* Defaults to 10 (ms)
|
||||
|
@ -3001,10 +2996,6 @@ declare namespace monaco.editor {
|
|||
* Syntax highlighting is copied.
|
||||
*/
|
||||
copyWithSyntaxHighlighting?: boolean;
|
||||
/**
|
||||
* Enable word based suggestions. Defaults to 'true'
|
||||
*/
|
||||
wordBasedSuggestions?: boolean;
|
||||
/**
|
||||
* The history mode for suggestions.
|
||||
*/
|
||||
|
@ -3022,7 +3013,7 @@ declare namespace monaco.editor {
|
|||
/**
|
||||
* Enable tab completion.
|
||||
*/
|
||||
tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets';
|
||||
tabCompletion?: 'on' | 'off' | 'onlySnippets';
|
||||
/**
|
||||
* Enable selection highlight.
|
||||
* Defaults to true.
|
||||
|
@ -3042,10 +3033,6 @@ declare namespace monaco.editor {
|
|||
* Control the behavior and rendering of the code action lightbulb.
|
||||
*/
|
||||
lightbulb?: IEditorLightbulbOptions;
|
||||
/**
|
||||
* Code action kinds to be run on save.
|
||||
*/
|
||||
codeActionsOnSave?: ICodeActionsOnSaveOptions;
|
||||
/**
|
||||
* Timeout for running code actions on save.
|
||||
*/
|
||||
|
@ -3262,59 +3249,6 @@ declare namespace monaco.editor {
|
|||
UnderlineThin = 6
|
||||
}
|
||||
|
||||
export interface InternalEditorFindOptions {
|
||||
readonly seedSearchStringFromSelection: boolean;
|
||||
readonly autoFindInSelection: boolean;
|
||||
readonly addExtraSpaceOnTop: boolean;
|
||||
}
|
||||
|
||||
export interface InternalEditorHoverOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly delay: number;
|
||||
readonly sticky: boolean;
|
||||
}
|
||||
|
||||
export interface InternalGoToLocationOptions {
|
||||
readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
export interface InternalSuggestOptions {
|
||||
readonly filterGraceful: boolean;
|
||||
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
|
||||
readonly snippetsPreventQuickSuggestions: boolean;
|
||||
readonly localityBonus: boolean;
|
||||
readonly shareSuggestSelections: boolean;
|
||||
readonly showIcons: boolean;
|
||||
readonly maxVisibleSuggestions: number;
|
||||
readonly filteredTypes: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export interface InternalParameterHintOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly cycle: boolean;
|
||||
}
|
||||
|
||||
export interface EditorContribOptions {
|
||||
readonly hover: InternalEditorHoverOptions;
|
||||
readonly quickSuggestions: boolean | {
|
||||
other: boolean;
|
||||
comments: boolean;
|
||||
strings: boolean;
|
||||
};
|
||||
readonly parameterHints: InternalParameterHintOptions;
|
||||
readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
|
||||
readonly suggestFontSize: number;
|
||||
readonly suggestLineHeight: number;
|
||||
readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
|
||||
readonly suggest: InternalSuggestOptions;
|
||||
readonly gotoLocation: InternalGoToLocationOptions;
|
||||
readonly foldingStrategy: 'auto' | 'indentation';
|
||||
readonly showFoldingControls: 'always' | 'mouseover';
|
||||
readonly find: InternalEditorFindOptions;
|
||||
readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
|
||||
readonly codeActionsOnSaveTimeout: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal configuration options (transformed or computed) for the editor.
|
||||
*/
|
||||
|
@ -3323,7 +3257,6 @@ declare namespace monaco.editor {
|
|||
readonly pixelRatio: number;
|
||||
readonly lineHeight: number;
|
||||
readonly fontInfo: FontInfo;
|
||||
readonly contribInfo: EditorContribOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3334,7 +3267,6 @@ declare namespace monaco.editor {
|
|||
readonly pixelRatio: boolean;
|
||||
readonly lineHeight: boolean;
|
||||
readonly fontInfo: boolean;
|
||||
readonly contribInfo: boolean;
|
||||
}
|
||||
|
||||
export interface IEnvironmentalOptions {
|
||||
|
@ -3383,6 +3315,14 @@ declare namespace monaco.editor {
|
|||
readonly maxColumn: number;
|
||||
}
|
||||
|
||||
export interface InternalEditorHoverOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly delay: number;
|
||||
readonly sticky: boolean;
|
||||
}
|
||||
|
||||
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;
|
||||
|
||||
export type ValidEditorLightbulbOptions = Required<IEditorLightbulbOptions>;
|
||||
|
||||
export interface InternalEditorScrollbarOptions {
|
||||
|
@ -3399,6 +3339,34 @@ declare namespace monaco.editor {
|
|||
readonly verticalSliderSize: number;
|
||||
}
|
||||
|
||||
export type ValidSuggestOptions = Readonly<Required<ISuggestOptions>>;
|
||||
|
||||
export interface InternalSuggestOptions {
|
||||
readonly filterGraceful: boolean;
|
||||
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
|
||||
readonly snippetsPreventQuickSuggestions: boolean;
|
||||
readonly localityBonus: boolean;
|
||||
readonly shareSuggestSelections: boolean;
|
||||
readonly showIcons: boolean;
|
||||
readonly maxVisibleSuggestions: number;
|
||||
readonly filteredTypes: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export interface InternalParameterHintOptions {
|
||||
readonly enabled: boolean;
|
||||
readonly cycle: boolean;
|
||||
}
|
||||
|
||||
export interface InternalEditorFindOptions {
|
||||
readonly seedSearchStringFromSelection: boolean;
|
||||
readonly autoFindInSelection: boolean;
|
||||
readonly addExtraSpaceOnTop: boolean;
|
||||
}
|
||||
|
||||
export interface InternalGoToLocationOptions {
|
||||
readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
|
||||
}
|
||||
|
||||
/**
|
||||
* A description for the overview ruler position.
|
||||
*/
|
||||
|
@ -3542,66 +3510,78 @@ declare namespace monaco.editor {
|
|||
emptySelectionClipboard = 20,
|
||||
extraEditorClassName = 21,
|
||||
fastScrollSensitivity = 22,
|
||||
fixedOverflowWidgets = 23,
|
||||
folding = 24,
|
||||
fontLigatures = 25,
|
||||
formatOnPaste = 26,
|
||||
formatOnType = 27,
|
||||
glyphMargin = 28,
|
||||
hideCursorInOverviewRuler = 29,
|
||||
highlightActiveIndentGuide = 30,
|
||||
inDiffEditor = 31,
|
||||
lightbulb = 32,
|
||||
lineDecorationsWidth = 33,
|
||||
lineNumbers = 34,
|
||||
lineNumbersMinChars = 35,
|
||||
links = 36,
|
||||
matchBrackets = 37,
|
||||
minimap = 38,
|
||||
mouseStyle = 39,
|
||||
mouseWheelScrollSensitivity = 40,
|
||||
mouseWheelZoom = 41,
|
||||
multiCursorMergeOverlapping = 42,
|
||||
multiCursorModifier = 43,
|
||||
occurrencesHighlight = 44,
|
||||
overviewRulerBorder = 45,
|
||||
overviewRulerLanes = 46,
|
||||
quickSuggestionsDelay = 47,
|
||||
readOnly = 48,
|
||||
renderControlCharacters = 49,
|
||||
renderIndentGuides = 50,
|
||||
renderFinalNewline = 51,
|
||||
renderLineHighlight = 52,
|
||||
renderWhitespace = 53,
|
||||
revealHorizontalRightPadding = 54,
|
||||
roundedSelection = 55,
|
||||
rulers = 56,
|
||||
scrollbar = 57,
|
||||
scrollBeyondLastColumn = 58,
|
||||
scrollBeyondLastLine = 59,
|
||||
selectionClipboard = 60,
|
||||
selectionHighlight = 61,
|
||||
selectOnLineNumbers = 62,
|
||||
showUnused = 63,
|
||||
smoothScrolling = 64,
|
||||
stopRenderingLineAfter = 65,
|
||||
suggestOnTriggerCharacters = 66,
|
||||
useTabStops = 67,
|
||||
wordBasedSuggestions = 68,
|
||||
wordSeparators = 69,
|
||||
wordWrap = 70,
|
||||
wordWrapBreakAfterCharacters = 71,
|
||||
wordWrapBreakBeforeCharacters = 72,
|
||||
wordWrapBreakObtrusiveCharacters = 73,
|
||||
wordWrapColumn = 74,
|
||||
wordWrapMinified = 75,
|
||||
wrappingIndent = 76,
|
||||
ariaLabel = 77,
|
||||
disableMonospaceOptimizations = 78,
|
||||
editorClassName = 79,
|
||||
tabFocusMode = 80,
|
||||
layoutInfo = 81,
|
||||
wrappingInfo = 82
|
||||
find = 23,
|
||||
fixedOverflowWidgets = 24,
|
||||
folding = 25,
|
||||
foldingStrategy = 26,
|
||||
fontLigatures = 27,
|
||||
formatOnPaste = 28,
|
||||
formatOnType = 29,
|
||||
glyphMargin = 30,
|
||||
gotoLocation = 31,
|
||||
hideCursorInOverviewRuler = 32,
|
||||
highlightActiveIndentGuide = 33,
|
||||
hover = 34,
|
||||
inDiffEditor = 35,
|
||||
lightbulb = 36,
|
||||
lineDecorationsWidth = 37,
|
||||
lineNumbers = 38,
|
||||
lineNumbersMinChars = 39,
|
||||
links = 40,
|
||||
matchBrackets = 41,
|
||||
minimap = 42,
|
||||
mouseStyle = 43,
|
||||
mouseWheelScrollSensitivity = 44,
|
||||
mouseWheelZoom = 45,
|
||||
multiCursorMergeOverlapping = 46,
|
||||
multiCursorModifier = 47,
|
||||
occurrencesHighlight = 48,
|
||||
overviewRulerBorder = 49,
|
||||
overviewRulerLanes = 50,
|
||||
parameterHints = 51,
|
||||
quickSuggestions = 52,
|
||||
quickSuggestionsDelay = 53,
|
||||
readOnly = 54,
|
||||
renderControlCharacters = 55,
|
||||
renderIndentGuides = 56,
|
||||
renderFinalNewline = 57,
|
||||
renderLineHighlight = 58,
|
||||
renderWhitespace = 59,
|
||||
revealHorizontalRightPadding = 60,
|
||||
roundedSelection = 61,
|
||||
rulers = 62,
|
||||
scrollbar = 63,
|
||||
scrollBeyondLastColumn = 64,
|
||||
scrollBeyondLastLine = 65,
|
||||
selectionClipboard = 66,
|
||||
selectionHighlight = 67,
|
||||
selectOnLineNumbers = 68,
|
||||
showFoldingControls = 69,
|
||||
showUnused = 70,
|
||||
snippetSuggestions = 71,
|
||||
smoothScrolling = 72,
|
||||
stopRenderingLineAfter = 73,
|
||||
suggestFontSize = 74,
|
||||
suggestLineHeight = 75,
|
||||
suggestOnTriggerCharacters = 76,
|
||||
suggestSelection = 77,
|
||||
tabCompletion = 78,
|
||||
useTabStops = 79,
|
||||
wordSeparators = 80,
|
||||
wordWrap = 81,
|
||||
wordWrapBreakAfterCharacters = 82,
|
||||
wordWrapBreakBeforeCharacters = 83,
|
||||
wordWrapBreakObtrusiveCharacters = 84,
|
||||
wordWrapColumn = 85,
|
||||
wordWrapMinified = 86,
|
||||
wrappingIndent = 87,
|
||||
ariaLabel = 88,
|
||||
disableMonospaceOptimizations = 89,
|
||||
editorClassName = 90,
|
||||
tabFocusMode = 91,
|
||||
suggest = 92,
|
||||
layoutInfo = 93,
|
||||
wrappingInfo = 94
|
||||
}
|
||||
|
||||
export const EditorOptions: {
|
||||
|
@ -3628,14 +3608,18 @@ declare namespace monaco.editor {
|
|||
emptySelectionClipboard: IEditorOption<EditorOption.emptySelectionClipboard, "emptySelectionClipboard", boolean, boolean>;
|
||||
extraEditorClassName: IEditorOption<EditorOption.extraEditorClassName, "extraEditorClassName", string, string>;
|
||||
fastScrollSensitivity: IEditorOption<EditorOption.fastScrollSensitivity, "fastScrollSensitivity", number, number>;
|
||||
find: IEditorOption<EditorOption.find, "find", InternalEditorFindOptions, InternalEditorFindOptions>;
|
||||
fixedOverflowWidgets: IEditorOption<EditorOption.fixedOverflowWidgets, "fixedOverflowWidgets", boolean, boolean>;
|
||||
folding: IEditorOption<EditorOption.folding, "folding", boolean, boolean>;
|
||||
foldingStrategy: IEditorOption<EditorOption.foldingStrategy, "foldingStrategy", "auto" | "indentation", "auto" | "indentation">;
|
||||
fontLigatures: IEditorOption<EditorOption.fontLigatures, "fontLigatures", boolean, boolean>;
|
||||
formatOnPaste: IEditorOption<EditorOption.formatOnPaste, "formatOnPaste", boolean, boolean>;
|
||||
formatOnType: IEditorOption<EditorOption.formatOnType, "formatOnType", boolean, boolean>;
|
||||
glyphMargin: IEditorOption<EditorOption.glyphMargin, "glyphMargin", boolean, boolean>;
|
||||
gotoLocation: IEditorOption<EditorOption.gotoLocation, "gotoLocation", InternalGoToLocationOptions, InternalGoToLocationOptions>;
|
||||
hideCursorInOverviewRuler: IEditorOption<EditorOption.hideCursorInOverviewRuler, "hideCursorInOverviewRuler", boolean, boolean>;
|
||||
highlightActiveIndentGuide: IEditorOption<EditorOption.highlightActiveIndentGuide, "highlightActiveIndentGuide", boolean, boolean>;
|
||||
hover: IEditorOption<EditorOption.hover, "hover", InternalEditorHoverOptions, InternalEditorHoverOptions>;
|
||||
inDiffEditor: IEditorOption<EditorOption.inDiffEditor, "inDiffEditor", boolean, boolean>;
|
||||
lightbulb: IEditorOption<EditorOption.lightbulb, "lightbulb", any, any>;
|
||||
lineDecorationsWidth: IEditorOption<EditorOption.lineDecorationsWidth, "lineDecorationsWidth", string | number, string | number>;
|
||||
|
@ -3652,6 +3636,8 @@ declare namespace monaco.editor {
|
|||
occurrencesHighlight: IEditorOption<EditorOption.occurrencesHighlight, "occurrencesHighlight", boolean, boolean>;
|
||||
overviewRulerBorder: IEditorOption<EditorOption.overviewRulerBorder, "overviewRulerBorder", boolean, boolean>;
|
||||
overviewRulerLanes: IEditorOption<EditorOption.overviewRulerLanes, "overviewRulerLanes", number, number>;
|
||||
parameterHints: IEditorOption<EditorOption.parameterHints, "parameterHints", InternalParameterHintOptions, InternalParameterHintOptions>;
|
||||
quickSuggestions: IEditorOption<EditorOption.quickSuggestions, "quickSuggestions", any, any>;
|
||||
quickSuggestionsDelay: IEditorOption<EditorOption.quickSuggestionsDelay, "quickSuggestionsDelay", number, number>;
|
||||
readOnly: IEditorOption<EditorOption.readOnly, "readOnly", boolean, boolean>;
|
||||
renderControlCharacters: IEditorOption<EditorOption.renderControlCharacters, "renderControlCharacters", boolean, boolean>;
|
||||
|
@ -3668,12 +3654,17 @@ declare namespace monaco.editor {
|
|||
selectionClipboard: IEditorOption<EditorOption.selectionClipboard, "selectionClipboard", boolean, boolean>;
|
||||
selectionHighlight: IEditorOption<EditorOption.selectionHighlight, "selectionHighlight", boolean, boolean>;
|
||||
selectOnLineNumbers: IEditorOption<EditorOption.selectOnLineNumbers, "selectOnLineNumbers", boolean, boolean>;
|
||||
showFoldingControls: IEditorOption<EditorOption.showFoldingControls, "showFoldingControls", "always" | "mouseover", "always" | "mouseover">;
|
||||
showUnused: IEditorOption<EditorOption.showUnused, "showUnused", boolean, boolean>;
|
||||
snippetSuggestions: IEditorOption<EditorOption.snippetSuggestions, "snippetSuggestions", "none" | "top" | "bottom" | "inline", "none" | "top" | "bottom" | "inline">;
|
||||
smoothScrolling: IEditorOption<EditorOption.smoothScrolling, "smoothScrolling", boolean, boolean>;
|
||||
stopRenderingLineAfter: IEditorOption<EditorOption.stopRenderingLineAfter, "stopRenderingLineAfter", number, number>;
|
||||
suggestFontSize: IEditorOption<EditorOption.suggestFontSize, "suggestFontSize", number, number>;
|
||||
suggestLineHeight: IEditorOption<EditorOption.suggestLineHeight, "suggestLineHeight", number, number>;
|
||||
suggestOnTriggerCharacters: IEditorOption<EditorOption.suggestOnTriggerCharacters, "suggestOnTriggerCharacters", boolean, boolean>;
|
||||
suggestSelection: IEditorOption<EditorOption.suggestSelection, "suggestSelection", "first" | "recentlyUsed" | "recentlyUsedByPrefix", "first" | "recentlyUsed" | "recentlyUsedByPrefix">;
|
||||
tabCompletion: IEditorOption<EditorOption.tabCompletion, "tabCompletion", "on" | "off" | "onlySnippets", "on" | "off" | "onlySnippets">;
|
||||
useTabStops: IEditorOption<EditorOption.useTabStops, "useTabStops", boolean, boolean>;
|
||||
wordBasedSuggestions: IEditorOption<EditorOption.wordBasedSuggestions, "wordBasedSuggestions", boolean, boolean>;
|
||||
wordSeparators: IEditorOption<EditorOption.wordSeparators, "wordSeparators", string, string>;
|
||||
wordWrap: IEditorOption<EditorOption.wordWrap, "wordWrap", "on" | "off" | "wordWrapColumn" | "bounded", "on" | "off" | "wordWrapColumn" | "bounded">;
|
||||
wordWrapBreakAfterCharacters: IEditorOption<EditorOption.wordWrapBreakAfterCharacters, "wordWrapBreakAfterCharacters", string, string>;
|
||||
|
@ -3686,6 +3677,7 @@ declare namespace monaco.editor {
|
|||
disableMonospaceOptimizations: IEditorOption<EditorOption.disableMonospaceOptimizations, "disableMonospaceOptimizations", boolean, boolean>;
|
||||
editorClassName: IEditorOption<EditorOption.editorClassName, "editorClassName", undefined, string>;
|
||||
tabFocusMode: IEditorOption<EditorOption.tabFocusMode, "tabFocusMode", undefined, boolean>;
|
||||
suggest: IEditorOption<EditorOption.suggest, "suggest", any, InternalSuggestOptions>;
|
||||
layoutInfo: IEditorOption<EditorOption.layoutInfo, "layoutInfo", undefined, EditorLayoutInfo>;
|
||||
wrappingInfo: IEditorOption<EditorOption.wrappingInfo, "wrappingInfo", undefined, EditorWrappingInfo>;
|
||||
};
|
||||
|
|
|
@ -10,7 +10,6 @@ import { IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
|
|||
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { trimTrailingWhitespace } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
import { ICodeActionsOnSaveOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
@ -34,6 +33,10 @@ import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textF
|
|||
import { ISaveParticipant, SaveReason, IResolvedTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../common/extHost.protocol';
|
||||
|
||||
export interface ICodeActionsOnSaveOptions {
|
||||
[kind: string]: boolean;
|
||||
}
|
||||
|
||||
export interface ISaveParticipantParticipant extends ISaveParticipant {
|
||||
// progressMessage: string;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
|||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Snippet } from './snippetsFile';
|
||||
import { SnippetCompletion } from './snippetCompletionProvider';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class TabCompletionController implements editorCommon.IEditorContribution {
|
||||
|
||||
|
@ -42,7 +43,7 @@ export class TabCompletionController implements editorCommon.IEditorContribution
|
|||
) {
|
||||
this._hasSnippets = TabCompletionController.ContextKey.bindTo(contextKeyService);
|
||||
this._configListener = this._editor.onDidChangeConfiguration(e => {
|
||||
if (e.contribInfo) {
|
||||
if (e.hasChanged(EditorOption.tabCompletion)) {
|
||||
this._update();
|
||||
}
|
||||
});
|
||||
|
@ -59,7 +60,7 @@ export class TabCompletionController implements editorCommon.IEditorContribution
|
|||
}
|
||||
|
||||
private _update(): void {
|
||||
const enabled = this._editor.getConfiguration().contribInfo.tabCompletion === 'onlySnippets';
|
||||
const enabled = this._editor.getOption(EditorOption.tabCompletion) === 'onlySnippets';
|
||||
if (this._enabled !== enabled) {
|
||||
this._enabled = enabled;
|
||||
if (!this._enabled) {
|
||||
|
|
Loading…
Reference in a new issue