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

better settings name, #41060

上级 7a6fbe0a
......@@ -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',
......
......@@ -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,
......
......@@ -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();
......
......@@ -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);
......
......@@ -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;
......
......@@ -98,7 +98,7 @@ const configurationValueWhitelist = [
'editor.snippetSuggestions',
'editor.emptySelectionClipboard',
'editor.wordBasedSuggestions',
'editor.suggestHistory',
'editor.selectSuggestions',
'editor.suggestFontSize',
'editor.suggestLineHeight',
'editor.selectionHighlight',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册