提交 faa7f4c6 编写于 作者: J Johannes Rieken

better settings name, #41060

上级 7a6fbe0a
...@@ -468,11 +468,16 @@ const editorConfiguration: IConfigurationNode = { ...@@ -468,11 +468,16 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions, 'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions,
'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.") 'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
}, },
'editor.suggestHistory': { 'editor.selectSuggestions': {
'type': 'string', 'type': 'string',
'enum': ['off', 'whenEmpty', 'byPrefix'], 'enum': ['never', 'byRecency', 'byPrefix'],
'default': 'whenEmpty', 'enumDescriptions': [
'description': nls.localize('suggestHistory', "Controls whether completions are selected based on previous completion sessions.") 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': { 'editor.suggestFontSize': {
'type': 'integer', 'type': 'integer',
......
...@@ -460,7 +460,7 @@ export interface IEditorOptions { ...@@ -460,7 +460,7 @@ export interface IEditorOptions {
/** /**
* The history mode for suggestions. * The history mode for suggestions.
*/ */
suggestHistory?: string; selectSuggestions?: string;
/** /**
* The font size for the suggest widget. * The font size for the suggest widget.
* Defaults to the editor font size. * Defaults to the editor font size.
...@@ -831,7 +831,7 @@ export interface EditorContribOptions { ...@@ -831,7 +831,7 @@ export interface EditorContribOptions {
readonly acceptSuggestionOnCommitCharacter: boolean; readonly acceptSuggestionOnCommitCharacter: boolean;
readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
readonly wordBasedSuggestions: boolean; readonly wordBasedSuggestions: boolean;
readonly suggestHistory: 'off' | 'whenEmpty' | 'byPrefix'; readonly selectSuggestions: 'never' | 'byRecency' | 'byPrefix';
readonly suggestFontSize: number; readonly suggestFontSize: number;
readonly suggestLineHeight: number; readonly suggestLineHeight: number;
readonly selectionHighlight: boolean; readonly selectionHighlight: boolean;
...@@ -1181,7 +1181,7 @@ export class InternalEditorOptions { ...@@ -1181,7 +1181,7 @@ export class InternalEditorOptions {
&& a.acceptSuggestionOnCommitCharacter === b.acceptSuggestionOnCommitCharacter && a.acceptSuggestionOnCommitCharacter === b.acceptSuggestionOnCommitCharacter
&& a.snippetSuggestions === b.snippetSuggestions && a.snippetSuggestions === b.snippetSuggestions
&& a.wordBasedSuggestions === b.wordBasedSuggestions && a.wordBasedSuggestions === b.wordBasedSuggestions
&& a.suggestHistory === b.suggestHistory && a.selectSuggestions === b.selectSuggestions
&& a.suggestFontSize === b.suggestFontSize && a.suggestFontSize === b.suggestFontSize
&& a.suggestLineHeight === b.suggestLineHeight && a.suggestLineHeight === b.suggestLineHeight
&& a.selectionHighlight === b.selectionHighlight && a.selectionHighlight === b.selectionHighlight
...@@ -1712,7 +1712,7 @@ export class EditorOptionsValidator { ...@@ -1712,7 +1712,7 @@ export class EditorOptionsValidator {
acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter), acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter),
snippetSuggestions: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippetSuggestions, ['top', 'bottom', 'inline', 'none']), snippetSuggestions: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippetSuggestions, ['top', 'bottom', 'inline', 'none']),
wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions), 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), suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000), suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight), selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
...@@ -1813,7 +1813,7 @@ export class InternalEditorOptionsFactory { ...@@ -1813,7 +1813,7 @@ export class InternalEditorOptionsFactory {
acceptSuggestionOnCommitCharacter: opts.contribInfo.acceptSuggestionOnCommitCharacter, acceptSuggestionOnCommitCharacter: opts.contribInfo.acceptSuggestionOnCommitCharacter,
snippetSuggestions: opts.contribInfo.snippetSuggestions, snippetSuggestions: opts.contribInfo.snippetSuggestions,
wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions, wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions,
suggestHistory: opts.contribInfo.suggestHistory, selectSuggestions: opts.contribInfo.selectSuggestions,
suggestFontSize: opts.contribInfo.suggestFontSize, suggestFontSize: opts.contribInfo.suggestFontSize,
suggestLineHeight: opts.contribInfo.suggestLineHeight, suggestLineHeight: opts.contribInfo.suggestLineHeight,
selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
...@@ -2268,7 +2268,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { ...@@ -2268,7 +2268,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
acceptSuggestionOnCommitCharacter: true, acceptSuggestionOnCommitCharacter: true,
snippetSuggestions: 'inline', snippetSuggestions: 'inline',
wordBasedSuggestions: true, wordBasedSuggestions: true,
suggestHistory: 'whenEmpty', selectSuggestions: 'byRecency',
suggestFontSize: 0, suggestFontSize: 0,
suggestLineHeight: 0, suggestLineHeight: 0,
selectionHighlight: true, selectionHighlight: true,
......
...@@ -95,7 +95,7 @@ export class SuggestController implements IEditorContribution { ...@@ -95,7 +95,7 @@ export class SuggestController implements IEditorContribution {
@IInstantiationService private _instantiationService: IInstantiationService, @IInstantiationService private _instantiationService: IInstantiationService,
) { ) {
this._model = new SuggestModel(this._editor); 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 => { this._toDispose.push(this._model.onDidTrigger(e => {
if (!this._widget) { if (!this._widget) {
...@@ -116,9 +116,9 @@ export class SuggestController implements IEditorContribution { ...@@ -116,9 +116,9 @@ export class SuggestController implements IEditorContribution {
// Manage the acceptSuggestionsOnEnter context key // Manage the acceptSuggestionsOnEnter context key
let acceptSuggestionsOnEnter = SuggestContext.AcceptSuggestionsOnEnter.bindTo(_contextKeyService); let acceptSuggestionsOnEnter = SuggestContext.AcceptSuggestionsOnEnter.bindTo(_contextKeyService);
let updateFromConfig = () => { let updateFromConfig = () => {
const { acceptSuggestionOnEnter, suggestHistory } = this._editor.getConfiguration().contribInfo; const { acceptSuggestionOnEnter, selectSuggestions } = this._editor.getConfiguration().contribInfo;
acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart'); acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart');
this._memory.setMode(suggestHistory); this._memory.setMode(selectSuggestions);
}; };
this._toDispose.push(this._editor.onDidChangeConfiguration((e) => updateFromConfig())); this._toDispose.push(this._editor.onDidChangeConfiguration((e) => updateFromConfig()));
updateFromConfig(); updateFromConfig();
......
...@@ -165,7 +165,7 @@ export class PrefixMemory extends Memory { ...@@ -165,7 +165,7 @@ export class PrefixMemory extends Memory {
} }
} }
export type MemMode = 'off' | 'whenEmpty' | 'byPrefix'; export type MemMode = 'never' | 'byRecency' | 'byPrefix';
export class SuggestMemories { export class SuggestMemories {
...@@ -188,7 +188,7 @@ export class SuggestMemories { ...@@ -188,7 +188,7 @@ export class SuggestMemories {
return; return;
} }
this._mode = mode; 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 { try {
const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE); const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE);
......
...@@ -2745,7 +2745,7 @@ declare module monaco.editor { ...@@ -2745,7 +2745,7 @@ declare module monaco.editor {
/** /**
* The history mode for suggestions. * The history mode for suggestions.
*/ */
suggestHistory?: string; selectSuggestions?: string;
/** /**
* The font size for the suggest widget. * The font size for the suggest widget.
* Defaults to the editor font size. * Defaults to the editor font size.
...@@ -3052,7 +3052,7 @@ declare module monaco.editor { ...@@ -3052,7 +3052,7 @@ declare module monaco.editor {
readonly acceptSuggestionOnCommitCharacter: boolean; readonly acceptSuggestionOnCommitCharacter: boolean;
readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
readonly wordBasedSuggestions: boolean; readonly wordBasedSuggestions: boolean;
readonly suggestHistory: 'off' | 'whenEmpty' | 'byPrefix'; readonly selectSuggestions: 'never' | 'byRecency' | 'byPrefix';
readonly suggestFontSize: number; readonly suggestFontSize: number;
readonly suggestLineHeight: number; readonly suggestLineHeight: number;
readonly selectionHighlight: boolean; readonly selectionHighlight: boolean;
......
...@@ -98,7 +98,7 @@ const configurationValueWhitelist = [ ...@@ -98,7 +98,7 @@ const configurationValueWhitelist = [
'editor.snippetSuggestions', 'editor.snippetSuggestions',
'editor.emptySelectionClipboard', 'editor.emptySelectionClipboard',
'editor.wordBasedSuggestions', 'editor.wordBasedSuggestions',
'editor.suggestHistory', 'editor.selectSuggestions',
'editor.suggestFontSize', 'editor.suggestFontSize',
'editor.suggestLineHeight', 'editor.suggestLineHeight',
'editor.selectionHighlight', 'editor.selectionHighlight',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册