提交 cb0af822 编写于 作者: P pkoushik

fix-62365 : Added useGlobalStorageForSuggestions Setting

上级 aa4ef3a4
......@@ -639,6 +639,11 @@ const editorConfiguration: IConfigurationNode = {
default: false,
description: nls.localize('suggest.localityBonus', "Controls whether sorting favours words that appear close to the cursor.")
},
'editor.suggest.useGlobalStorageForSuggestions': {
type: 'boolean',
default: false,
description: nls.localize('suggest.useGlobalStorageForSuggestions', "Controls whether global storage is used for remembering suggestions.")
},
'editor.suggest.snippetsPreventQuickSuggestions': {
type: 'boolean',
default: true,
......
......@@ -194,6 +194,11 @@ export interface ISuggestOptions {
* Favours words that appear close to the cursor.
*/
localityBonus?: boolean;
/**
* Enable using global storage for remembering suggestions.
*/
useGlobalStorageForSuggestions?: boolean;
}
/**
......@@ -900,6 +905,7 @@ export interface InternalSuggestOptions {
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly useGlobalStorageForSuggestions: boolean;
}
export interface InternalParameterHintOptions {
......@@ -1346,7 +1352,8 @@ export class InternalEditorOptions {
return a.filterGraceful === b.filterGraceful
&& a.snippets === b.snippets
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
&& a.localityBonus === b.localityBonus;
&& a.localityBonus === b.localityBonus
&& a.useGlobalStorageForSuggestions === b.useGlobalStorageForSuggestions;
}
}
......@@ -1877,6 +1884,7 @@ export class EditorOptionsValidator {
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),
useGlobalStorageForSuggestions: _boolean(suggestOpts.useGlobalStorageForSuggestions, defaults.useGlobalStorageForSuggestions)
};
}
......@@ -2625,7 +2633,8 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
filterGraceful: true,
snippets: 'inline',
snippetsPreventQuickSuggestions: true,
localityBonus: false
localityBonus: false,
useGlobalStorageForSuggestions: false
},
selectionHighlight: true,
occurrencesHighlight: true,
......
......@@ -206,12 +206,12 @@ export class SuggestMemories extends Disposable {
) {
super();
this._setMode(editor.getConfiguration().contribInfo.suggestSelection);
this._register(editor.onDidChangeConfiguration(e => e.contribInfo && this._setMode(editor.getConfiguration().contribInfo.suggestSelection)));
this._setMode(editor.getConfiguration().contribInfo.suggestSelection, editor.getConfiguration().contribInfo.suggest.useGlobalStorageForSuggestions);
this._register(editor.onDidChangeConfiguration(e => e.contribInfo && this._setMode(editor.getConfiguration().contribInfo.suggestSelection, editor.getConfiguration().contribInfo.suggest.useGlobalStorageForSuggestions)));
this._register(_storageService.onWillSaveState(() => this._saveState()));
}
private _setMode(mode: MemMode): void {
private _setMode(mode: MemMode, useGlobalStorageForSuggestions: boolean): void {
if (this._mode === mode) {
return;
}
......@@ -219,7 +219,7 @@ export class SuggestMemories extends Disposable {
this._strategy = mode === 'recentlyUsedByPrefix' ? new PrefixMemory() : mode === 'recentlyUsed' ? new LRUMemory() : new NoMemory();
try {
const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE);
const raw = useGlobalStorageForSuggestions ? this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.GLOBAL) : this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE);
if (raw) {
this._strategy.fromJSON(JSON.parse(raw));
}
......
......@@ -165,7 +165,7 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'top', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false });
}, WordDistance.None, { snippets: 'top', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, useGlobalStorageForSuggestions: false });
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......@@ -184,7 +184,7 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'bottom', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false });
}, WordDistance.None, { snippets: 'bottom', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, useGlobalStorageForSuggestions: false });
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......@@ -202,7 +202,7 @@ suite('CompletionModel', function () {
], 1, {
leadingLineContent: 's',
characterCountDelta: 0
}, WordDistance.None, { snippets: 'inline', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false });
}, WordDistance.None, { snippets: 'inline', snippetsPreventQuickSuggestions: true, filterGraceful: true, localityBonus: false, useGlobalStorageForSuggestions: false });
assert.equal(model.items.length, 2);
const [a, b] = model.items;
......
......@@ -2558,6 +2558,10 @@ declare namespace monaco.editor {
* Favours words that appear close to the cursor.
*/
localityBonus?: boolean;
/**
* Enable using global storage for remembering suggestions.
*/
useGlobalStorageForSuggestions?: boolean;
}
/**
......@@ -3193,6 +3197,7 @@ declare namespace monaco.editor {
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly useGlobalStorageForSuggestions: boolean;
}
export interface InternalParameterHintOptions {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册