From faa7f4c6592393a18db1da8d8654c58f6d9bdf12 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 26 Jan 2018 15:45:10 +0100 Subject: [PATCH] better settings name, #41060 --- src/vs/editor/common/config/commonEditorConfig.ts | 13 +++++++++---- src/vs/editor/common/config/editorOptions.ts | 12 ++++++------ src/vs/editor/contrib/suggest/suggestController.ts | 6 +++--- src/vs/editor/contrib/suggest/suggestMemory.ts | 4 ++-- src/vs/monaco.d.ts | 4 ++-- src/vs/platform/telemetry/common/telemetryUtils.ts | 2 +- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index bf4f1a7fc41..12d923aa696 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -468,11 +468,16 @@ const editorConfiguration: IConfigurationNode = { 'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions, 'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.") }, - 'editor.suggestHistory': { + 'editor.selectSuggestions': { 'type': 'string', - 'enum': ['off', 'whenEmpty', 'byPrefix'], - 'default': 'whenEmpty', - 'description': nls.localize('suggestHistory', "Controls whether completions are selected based on previous completion sessions.") + 'enum': ['never', 'byRecency', 'byPrefix'], + 'enumDescriptions': [ + nls.localize('selectSuggestions.never', "Do not remember suggestions and always select the first."), + nls.localize('selectSuggestions.byRecency', "Select recent suggestions unless further typing selects one, e.g. `console.| -> console.log`"), + nls.localize('selectSuggestions.byPrefix', "Select suggestions based on previous prefixes that have completed those suggestions, e.g. `co -> console` and `con -> const`"), + ], + 'default': 'byRecency', + 'description': nls.localize('selectSuggestions', "Controls if accepting suggestions changes how future suggestions are pre-selected.") }, 'editor.suggestFontSize': { 'type': 'integer', diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index fd183e99f8c..9b76f7ea2dc 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -460,7 +460,7 @@ export interface IEditorOptions { /** * The history mode for suggestions. */ - suggestHistory?: string; + selectSuggestions?: string; /** * The font size for the suggest widget. * Defaults to the editor font size. @@ -831,7 +831,7 @@ export interface EditorContribOptions { readonly acceptSuggestionOnCommitCharacter: boolean; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; readonly wordBasedSuggestions: boolean; - readonly suggestHistory: 'off' | 'whenEmpty' | 'byPrefix'; + readonly selectSuggestions: 'never' | 'byRecency' | 'byPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; readonly selectionHighlight: boolean; @@ -1181,7 +1181,7 @@ export class InternalEditorOptions { && a.acceptSuggestionOnCommitCharacter === b.acceptSuggestionOnCommitCharacter && a.snippetSuggestions === b.snippetSuggestions && a.wordBasedSuggestions === b.wordBasedSuggestions - && a.suggestHistory === b.suggestHistory + && a.selectSuggestions === b.selectSuggestions && a.suggestFontSize === b.suggestFontSize && a.suggestLineHeight === b.suggestLineHeight && a.selectionHighlight === b.selectionHighlight @@ -1712,7 +1712,7 @@ export class EditorOptionsValidator { acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter), snippetSuggestions: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippetSuggestions, ['top', 'bottom', 'inline', 'none']), wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions), - suggestHistory: _stringSet<'off' | 'whenEmpty' | 'byPrefix'>(opts.suggestHistory, defaults.suggestHistory, ['off', 'whenEmpty', 'byPrefix']), + selectSuggestions: _stringSet<'never' | 'byRecency' | 'byPrefix'>(opts.selectSuggestions, defaults.selectSuggestions, ['never', 'byRecency', 'byPrefix']), suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000), suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000), selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight), @@ -1813,7 +1813,7 @@ export class InternalEditorOptionsFactory { acceptSuggestionOnCommitCharacter: opts.contribInfo.acceptSuggestionOnCommitCharacter, snippetSuggestions: opts.contribInfo.snippetSuggestions, wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions, - suggestHistory: opts.contribInfo.suggestHistory, + selectSuggestions: opts.contribInfo.selectSuggestions, suggestFontSize: opts.contribInfo.suggestFontSize, suggestLineHeight: opts.contribInfo.suggestLineHeight, selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED @@ -2268,7 +2268,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { acceptSuggestionOnCommitCharacter: true, snippetSuggestions: 'inline', wordBasedSuggestions: true, - suggestHistory: 'whenEmpty', + selectSuggestions: 'byRecency', suggestFontSize: 0, suggestLineHeight: 0, selectionHighlight: true, diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index 35fc83c1195..b3a73b17cd9 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -95,7 +95,7 @@ export class SuggestController implements IEditorContribution { @IInstantiationService private _instantiationService: IInstantiationService, ) { this._model = new SuggestModel(this._editor); - this._memory = _instantiationService.createInstance(SuggestMemories, this._editor.getConfiguration().contribInfo.suggestHistory); + this._memory = _instantiationService.createInstance(SuggestMemories, this._editor.getConfiguration().contribInfo.selectSuggestions); this._toDispose.push(this._model.onDidTrigger(e => { if (!this._widget) { @@ -116,9 +116,9 @@ export class SuggestController implements IEditorContribution { // Manage the acceptSuggestionsOnEnter context key let acceptSuggestionsOnEnter = SuggestContext.AcceptSuggestionsOnEnter.bindTo(_contextKeyService); let updateFromConfig = () => { - const { acceptSuggestionOnEnter, suggestHistory } = this._editor.getConfiguration().contribInfo; + const { acceptSuggestionOnEnter, selectSuggestions } = this._editor.getConfiguration().contribInfo; acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart'); - this._memory.setMode(suggestHistory); + this._memory.setMode(selectSuggestions); }; this._toDispose.push(this._editor.onDidChangeConfiguration((e) => updateFromConfig())); updateFromConfig(); diff --git a/src/vs/editor/contrib/suggest/suggestMemory.ts b/src/vs/editor/contrib/suggest/suggestMemory.ts index ba1c9aa2d2c..e434231cf0e 100644 --- a/src/vs/editor/contrib/suggest/suggestMemory.ts +++ b/src/vs/editor/contrib/suggest/suggestMemory.ts @@ -165,7 +165,7 @@ export class PrefixMemory extends Memory { } } -export type MemMode = 'off' | 'whenEmpty' | 'byPrefix'; +export type MemMode = 'never' | 'byRecency' | 'byPrefix'; export class SuggestMemories { @@ -188,7 +188,7 @@ export class SuggestMemories { return; } this._mode = mode; - this._strategy = mode === 'byPrefix' ? new PrefixMemory() : mode === 'whenEmpty' ? new LRUMemory() : new NoMemory(); + this._strategy = mode === 'byPrefix' ? new PrefixMemory() : mode === 'byRecency' ? new LRUMemory() : new NoMemory(); try { const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index df0750d76d4..a4857e58502 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2745,7 +2745,7 @@ declare module monaco.editor { /** * The history mode for suggestions. */ - suggestHistory?: string; + selectSuggestions?: string; /** * The font size for the suggest widget. * Defaults to the editor font size. @@ -3052,7 +3052,7 @@ declare module monaco.editor { readonly acceptSuggestionOnCommitCharacter: boolean; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; readonly wordBasedSuggestions: boolean; - readonly suggestHistory: 'off' | 'whenEmpty' | 'byPrefix'; + readonly selectSuggestions: 'never' | 'byRecency' | 'byPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; readonly selectionHighlight: boolean; diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index 5fd62f2a1d7..73b4bcf93cb 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -98,7 +98,7 @@ const configurationValueWhitelist = [ 'editor.snippetSuggestions', 'editor.emptySelectionClipboard', 'editor.wordBasedSuggestions', - 'editor.suggestHistory', + 'editor.selectSuggestions', 'editor.suggestFontSize', 'editor.suggestLineHeight', 'editor.selectionHighlight', -- GitLab