diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 7b49c05eaea50..8578d82799f52 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -324,11 +324,11 @@ export const completionKindToCssClass = (function () { /** * @internal */ -export let completionKindFromLegacyString = (function () { - let data = Object.create(null); +export let completionKindFromString = (function () { + let data: Record = Object.create(null); data['method'] = CompletionItemKind.Method; data['function'] = CompletionItemKind.Function; - data['constructor'] = CompletionItemKind.Constructor; + data['constructor'] = CompletionItemKind.Constructor; data['field'] = CompletionItemKind.Field; data['variable'] = CompletionItemKind.Variable; data['class'] = CompletionItemKind.Class; @@ -354,7 +354,7 @@ export let completionKindFromLegacyString = (function () { data['type-parameter'] = CompletionItemKind.TypeParameter; return function (value: string) { - return data[value] || 'property'; + return data[value] || CompletionItemKind.Property; }; })(); diff --git a/src/vs/editor/contrib/suggest/suggest.ts b/src/vs/editor/contrib/suggest/suggest.ts index b068415b791ff..045aadd0b431a 100644 --- a/src/vs/editor/contrib/suggest/suggest.ts +++ b/src/vs/editor/contrib/suggest/suggest.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { first } from 'vs/base/common/async'; -import { isNonEmptyArray } from 'vs/base/common/arrays'; import { assign } from 'vs/base/common/objects'; import { onUnexpectedExternalError, canceled, isPromiseCanceledError } from 'vs/base/common/errors'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -87,7 +86,20 @@ export class CompletionItem { } } -export type SnippetConfig = 'top' | 'bottom' | 'inline' | 'none'; +export const enum SnippetSortOrder { + Top, Inline, Bottom +} + +export class CompletionOptions { + + static readonly default = new CompletionOptions(); + + constructor( + readonly snippetSortOrder = SnippetSortOrder.Bottom, + readonly kindFilter = new Set(), + readonly providerFilter = new Set(), + ) { } +} let _snippetSuggestSupport: modes.CompletionItemProvider; @@ -104,15 +116,12 @@ export function setSnippetSuggestSupport(support: modes.CompletionItemProvider): export function provideSuggestionItems( model: ITextModel, position: Position, - snippetConfig: SnippetConfig = 'bottom', - onlyFrom?: modes.CompletionItemProvider[], - context?: modes.CompletionContext, + options: CompletionOptions = CompletionOptions.default, + context: modes.CompletionContext = { triggerKind: modes.CompletionTriggerKind.Invoke }, token: CancellationToken = CancellationToken.None ): Promise { const allSuggestions: CompletionItem[] = []; - const acceptSuggestion = createSuggesionFilter(snippetConfig); - const wordUntil = model.getWordUntilPosition(position); const defaultRange = new Range(position.lineNumber, wordUntil.startColumn, position.lineNumber, wordUntil.endColumn); @@ -122,12 +131,10 @@ export function provideSuggestionItems( const supports = modes.CompletionProviderRegistry.orderedGroups(model); // add snippets provider unless turned off - if (snippetConfig !== 'none' && _snippetSuggestSupport) { + if (!options.kindFilter.has(modes.CompletionItemKind.Snippet) && _snippetSuggestSupport) { supports.unshift([_snippetSuggestSupport]); } - const suggestConext = context || { triggerKind: modes.CompletionTriggerKind.Invoke }; - // add suggestions from contributed providers - providers are ordered in groups of // equal score and once a group produces a result the process stops let hasResult = false; @@ -135,17 +142,17 @@ export function provideSuggestionItems( // for each support in the group ask for suggestions return Promise.all(supports.map(provider => { - if (isNonEmptyArray(onlyFrom) && onlyFrom.indexOf(provider) < 0) { + if (options.providerFilter.size > 0 && !options.providerFilter.has(provider)) { return undefined; } - return Promise.resolve(provider.provideCompletionItems(model, position, suggestConext, token)).then(container => { + return Promise.resolve(provider.provideCompletionItems(model, position, context, token)).then(container => { const len = allSuggestions.length; if (container) { for (let suggestion of container.suggestions || []) { - if (acceptSuggestion(suggestion)) { + if (!options.kindFilter.has(suggestion.kind)) { // fill in default range when missing if (!suggestion.range) { @@ -172,7 +179,7 @@ export function provideSuggestionItems( if (token.isCancellationRequested) { return Promise.reject(canceled()); } - return allSuggestions.sort(getSuggestionComparator(snippetConfig)); + return allSuggestions.sort(getSuggestionComparator(options.snippetSortOrder)); }); // result.then(items => { @@ -185,13 +192,7 @@ export function provideSuggestionItems( return result; } -function createSuggesionFilter(snippetConfig: SnippetConfig): (candidate: modes.CompletionItem) => boolean { - if (snippetConfig === 'none') { - return suggestion => suggestion.kind !== modes.CompletionItemKind.Snippet; - } else { - return () => true; - } -} + function defaultComparator(a: CompletionItem, b: CompletionItem): number { // check with 'sortText' if (a.sortTextLow && b.sortTextLow) { @@ -233,14 +234,14 @@ function snippetDownComparator(a: CompletionItem, b: CompletionItem): number { return defaultComparator(a, b); } -export function getSuggestionComparator(snippetConfig: SnippetConfig): (a: CompletionItem, b: CompletionItem) => number { - if (snippetConfig === 'top') { - return snippetUpComparator; - } else if (snippetConfig === 'bottom') { - return snippetDownComparator; - } else { - return defaultComparator; - } +interface Comparator { (a: T, b: T): number; } +const _snippetComparators = new Map>(); +_snippetComparators.set(SnippetSortOrder.Top, snippetUpComparator); +_snippetComparators.set(SnippetSortOrder.Bottom, snippetDownComparator); +_snippetComparators.set(SnippetSortOrder.Inline, defaultComparator); + +export function getSuggestionComparator(snippetConfig: SnippetSortOrder): (a: CompletionItem, b: CompletionItem) => number { + return _snippetComparators.get(snippetConfig)!; } registerDefaultLanguageCommand('_executeCompletionItemProvider', (model, position, args) => { @@ -269,11 +270,10 @@ registerDefaultLanguageCommand('_executeCompletionItemProvider', (model, positio }); interface SuggestController extends IEditorContribution { - triggerSuggest(onlyFrom?: modes.CompletionItemProvider[]): void; + triggerSuggest(onlyFrom?: Set): void; } - -let _provider = new class implements modes.CompletionItemProvider { +const _provider = new class implements modes.CompletionItemProvider { onlyOnceSuggestions: modes.CompletionItem[] = []; @@ -290,6 +290,6 @@ modes.CompletionProviderRegistry.register('*', _provider); export function showSimpleSuggestions(editor: ICodeEditor, suggestions: modes.CompletionItem[]) { setTimeout(() => { _provider.onlyOnceSuggestions.push(...suggestions); - editor.getContribution('editor.contrib.suggestController').triggerSuggest([_provider]); + editor.getContribution('editor.contrib.suggestController').triggerSuggest(new Set().add(_provider)); }, 0); } diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index 833cb4a4308b9..c824573c90f4b 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -298,7 +298,7 @@ export class SuggestController implements IEditorContribution { } } - triggerSuggest(onlyFrom?: CompletionItemProvider[]): void { + triggerSuggest(onlyFrom?: Set): void { if (this._editor.hasModel()) { this._model.trigger({ auto: false, shy: false }, false, onlyFrom); this._editor.revealLine(this._editor.getPosition().lineNumber, ScrollType.Smooth); diff --git a/src/vs/editor/contrib/suggest/suggestMemory.ts b/src/vs/editor/contrib/suggest/suggestMemory.ts index f855098734b7d..e99c55af5d570 100644 --- a/src/vs/editor/contrib/suggest/suggestMemory.ts +++ b/src/vs/editor/contrib/suggest/suggestMemory.ts @@ -8,7 +8,7 @@ import { LRUCache, TernarySearchTree } from 'vs/base/common/map'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { ITextModel } from 'vs/editor/common/model'; import { IPosition } from 'vs/editor/common/core/position'; -import { CompletionItemKind, completionKindFromLegacyString } from 'vs/editor/common/modes'; +import { CompletionItemKind, completionKindFromString } from 'vs/editor/common/modes'; import { Disposable } from 'vs/base/common/lifecycle'; import { RunOnceScheduler } from 'vs/base/common/async'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -124,7 +124,7 @@ export class LRUMemory extends Memory { let seq = 0; for (const [key, value] of data) { value.touch = seq; - value.type = typeof value.type === 'number' ? value.type : completionKindFromLegacyString(value.type); + value.type = typeof value.type === 'number' ? value.type : completionKindFromString(value.type); this._cache.set(key, value); } this._seq = this._cache.size; @@ -188,7 +188,7 @@ export class PrefixMemory extends Memory { if (data.length > 0) { this._seq = data[0][1].touch + 1; for (const [key, value] of data) { - value.type = typeof value.type === 'number' ? value.type : completionKindFromLegacyString(value.type); + value.type = typeof value.type === 'number' ? value.type : completionKindFromString(value.type); this._trie.set(key, value); } } diff --git a/src/vs/editor/contrib/suggest/suggestModel.ts b/src/vs/editor/contrib/suggest/suggestModel.ts index 900f7b2d66b5c..c90e46ed0b5a3 100644 --- a/src/vs/editor/contrib/suggest/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/suggestModel.ts @@ -8,15 +8,14 @@ import { TimeoutTimer } from 'vs/base/common/async'; import { onUnexpectedError } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; -import { values } from 'vs/base/common/map'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { CursorChangeReason, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Selection } from 'vs/editor/common/core/selection'; import { ITextModel, IWordAtPosition } from 'vs/editor/common/model'; -import { CompletionItemProvider, StandardTokenType, CompletionContext, CompletionProviderRegistry, CompletionTriggerKind } from 'vs/editor/common/modes'; +import { CompletionItemProvider, StandardTokenType, CompletionContext, CompletionProviderRegistry, CompletionTriggerKind, CompletionItemKind } from 'vs/editor/common/modes'; import { CompletionModel } from './completionModel'; -import { CompletionItem, getSuggestionComparator, provideSuggestionItems, getSnippetSuggestSupport } from './suggest'; +import { CompletionItem, getSuggestionComparator, provideSuggestionItems, getSnippetSuggestSupport, SnippetSortOrder, CompletionOptions } from './suggest'; import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; @@ -209,7 +208,7 @@ export class SuggestModel implements IDisposable { // keep existing items that where not computed by the // supports/providers that want to trigger now const items: CompletionItem[] | undefined = this._completionModel ? this._completionModel.adopt(supports) : undefined; - this.trigger({ auto: true, shy: false, triggerCharacter: lastChar }, Boolean(this._completionModel), values(supports), items); + this.trigger({ auto: true, shy: false, triggerCharacter: lastChar }, Boolean(this._completionModel), supports, items); } }); } @@ -347,7 +346,7 @@ export class SuggestModel implements IDisposable { }, 25); } - trigger(context: SuggestTriggerContext, retrigger: boolean = false, onlyFrom?: CompletionItemProvider[], existingItems?: CompletionItem[]): void { + trigger(context: SuggestTriggerContext, retrigger: boolean = false, onlyFrom?: Set, existingItems?: CompletionItem[]): void { if (!this._editor.hasModel()) { return; } @@ -371,7 +370,7 @@ export class SuggestModel implements IDisposable { triggerKind: CompletionTriggerKind.TriggerCharacter, triggerCharacter: context.triggerCharacter }; - } else if (onlyFrom && onlyFrom.length) { + } else if (onlyFrom && onlyFrom.size > 0) { suggestCtx = { triggerKind: CompletionTriggerKind.TriggerForIncompleteCompletions }; } else { suggestCtx = { triggerKind: CompletionTriggerKind.Invoke }; @@ -379,13 +378,31 @@ export class SuggestModel implements IDisposable { this._requestToken = new CancellationTokenSource(); + // kind filter and snippet sort rules + let itemKindFilter = new Set(); + let snippetSortOrder = SnippetSortOrder.Inline; + switch (this._editor.getConfiguration().contribInfo.suggest.snippets) { + case 'top': + snippetSortOrder = SnippetSortOrder.Top; + break; + // ↓ that's the default anyways... + // case 'inline': + // snippetSortOrder = SnippetSortOrder.Inline; + // break; + case 'bottom': + snippetSortOrder = SnippetSortOrder.Bottom; + break; + case 'none': + itemKindFilter.add(CompletionItemKind.Snippet); + break; + } + let wordDistance = WordDistance.create(this._editorWorker, this._editor); let items = provideSuggestionItems( model, this._editor.getPosition(), - this._editor.getConfiguration().contribInfo.suggest.snippets, - onlyFrom, + new CompletionOptions(snippetSortOrder, itemKindFilter, onlyFrom), suggestCtx, this._requestToken.token ); @@ -405,7 +422,7 @@ export class SuggestModel implements IDisposable { const model = this._editor.getModel(); if (isNonEmptyArray(existingItems)) { - const cmpFn = getSuggestionComparator(this._editor.getConfiguration().contribInfo.suggest.snippets); + const cmpFn = getSuggestionComparator(snippetSortOrder); items = items.concat(existingItems).sort(cmpFn); } @@ -461,7 +478,7 @@ export class SuggestModel implements IDisposable { // typed -> moved cursor RIGHT & incomple model & still on a word -> retrigger const { incomplete } = this._completionModel; const adopted = this._completionModel.adopt(incomplete); - this.trigger({ auto: this._state === State.Auto, shy: false }, true, values(incomplete), adopted); + this.trigger({ auto: this._state === State.Auto, shy: false }, true, incomplete, adopted); } else { // typed -> moved cursor RIGHT -> update UI diff --git a/src/vs/editor/contrib/suggest/test/completionModel.test.ts b/src/vs/editor/contrib/suggest/test/completionModel.test.ts index d23a351069d1a..c180a6e8462e0 100644 --- a/src/vs/editor/contrib/suggest/test/completionModel.test.ts +++ b/src/vs/editor/contrib/suggest/test/completionModel.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { IPosition } from 'vs/editor/common/core/position'; import * as modes from 'vs/editor/common/modes'; import { CompletionModel } from 'vs/editor/contrib/suggest/completionModel'; -import { CompletionItem, getSuggestionComparator } from 'vs/editor/contrib/suggest/suggest'; +import { CompletionItem, getSuggestionComparator, SnippetSortOrder } from 'vs/editor/contrib/suggest/suggest'; import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance'; 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 { @@ -250,7 +250,7 @@ suite('CompletionModel', function () { const item1 = createSuggestItem('<- groups', 2, modes.CompletionItemKind.Property, false, { lineNumber: 1, column: 3 }, '00002', ' groups'); const item2 = createSuggestItem('source', 0, modes.CompletionItemKind.Property, false, { lineNumber: 1, column: 3 }, '00001', 'source'); - const items = [item1, item2].sort(getSuggestionComparator('inline')); + const items = [item1, item2].sort(getSuggestionComparator(SnippetSortOrder.Inline)); model = new CompletionModel(items, 3, { leadingLineContent: ' ', diff --git a/src/vs/editor/contrib/suggest/test/suggest.test.ts b/src/vs/editor/contrib/suggest/test/suggest.test.ts index c560e6e9b6ce2..da210d07ab25a 100644 --- a/src/vs/editor/contrib/suggest/test/suggest.test.ts +++ b/src/vs/editor/contrib/suggest/test/suggest.test.ts @@ -5,8 +5,8 @@ import * as assert from 'assert'; import { URI } from 'vs/base/common/uri'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { CompletionProviderRegistry, CompletionItemKind } from 'vs/editor/common/modes'; -import { provideSuggestionItems } from 'vs/editor/contrib/suggest/suggest'; +import { CompletionProviderRegistry, CompletionItemKind, CompletionItemProvider } from 'vs/editor/common/modes'; +import { provideSuggestionItems, SnippetSortOrder, CompletionOptions } from 'vs/editor/contrib/suggest/suggest'; import { Position } from 'vs/editor/common/core/position'; import { TextModel } from 'vs/editor/common/model/textModel'; import { Range } from 'vs/editor/common/core/range'; @@ -51,7 +51,7 @@ suite('Suggest', function () { }); test('sort - snippet inline', async function () { - const items = await provideSuggestionItems(model, new Position(1, 1), 'inline'); + const items = await provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(SnippetSortOrder.Inline)); assert.equal(items.length, 3); assert.equal(items[0].completion.label, 'aaa'); assert.equal(items[1].completion.label, 'fff'); @@ -59,7 +59,7 @@ suite('Suggest', function () { }); test('sort - snippet top', async function () { - const items = await provideSuggestionItems(model, new Position(1, 1), 'top'); + const items = await provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(SnippetSortOrder.Top)); assert.equal(items.length, 3); assert.equal(items[0].completion.label, 'aaa'); assert.equal(items[1].completion.label, 'zzz'); @@ -67,7 +67,7 @@ suite('Suggest', function () { }); test('sort - snippet bottom', async function () { - const items = await provideSuggestionItems(model, new Position(1, 1), 'bottom'); + const items = await provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(SnippetSortOrder.Bottom)); assert.equal(items.length, 3); assert.equal(items[0].completion.label, 'fff'); assert.equal(items[1].completion.label, 'aaa'); @@ -75,7 +75,7 @@ suite('Suggest', function () { }); test('sort - snippet none', async function () { - const items = await provideSuggestionItems(model, new Position(1, 1), 'none'); + const items = await provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(undefined, new Set().add(CompletionItemKind.Snippet))); assert.equal(items.length, 1); assert.equal(items[0].completion.label, 'fff'); }); @@ -98,7 +98,7 @@ suite('Suggest', function () { }; const registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, foo); - provideSuggestionItems(model, new Position(1, 1), undefined, [foo]).then(items => { + provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(undefined, undefined, new Set().add(foo))).then(items => { registration.dispose(); assert.equal(items.length, 1); diff --git a/src/vs/workbench/contrib/debug/electron-browser/breakpointWidget.ts b/src/vs/workbench/contrib/debug/electron-browser/breakpointWidget.ts index f711669b0b2c7..1fdfbf2dbf2f7 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/breakpointWidget.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/breakpointWidget.ts @@ -22,10 +22,10 @@ import { ServicesAccessor, EditorCommand, registerEditorCommand } from 'vs/edito import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { IModelService } from 'vs/editor/common/services/modelService'; import { URI as uri } from 'vs/base/common/uri'; -import { CompletionProviderRegistry, CompletionList, CompletionContext } from 'vs/editor/common/modes'; +import { CompletionProviderRegistry, CompletionList, CompletionContext, CompletionItemKind } from 'vs/editor/common/modes'; import { CancellationToken } from 'vs/base/common/cancellation'; import { ITextModel } from 'vs/editor/common/model'; -import { provideSuggestionItems } from 'vs/editor/contrib/suggest/suggest'; +import { provideSuggestionItems, CompletionOptions } from 'vs/editor/contrib/suggest/suggest'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { transparent, editorForeground } from 'vs/platform/theme/common/colorRegistry'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; @@ -232,7 +232,7 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi provideCompletionItems: (model: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise => { let suggestionsPromise: Promise; if (this.context === Context.CONDITION || this.context === Context.LOG_MESSAGE && this.isCurlyBracketOpen()) { - suggestionsPromise = provideSuggestionItems(this.editor.getModel(), new Position(this.lineNumber, 1), 'none', undefined, _context, token).then(suggestions => { + suggestionsPromise = provideSuggestionItems(this.editor.getModel(), new Position(this.lineNumber, 1), new CompletionOptions(undefined, new Set().add(CompletionItemKind.Snippet)), _context, token).then(suggestions => { let overwriteBefore = 0; if (this.context === Context.CONDITION) { diff --git a/src/vs/workbench/contrib/debug/electron-browser/debugSession.ts b/src/vs/workbench/contrib/debug/electron-browser/debugSession.ts index cd82b55507d09..71eca6ee41bce 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/debugSession.ts @@ -9,7 +9,7 @@ import * as nls from 'vs/nls'; import * as platform from 'vs/base/common/platform'; import severity from 'vs/base/common/severity'; import { Event, Emitter } from 'vs/base/common/event'; -import { CompletionItem, completionKindFromLegacyString } from 'vs/editor/common/modes'; +import { CompletionItem, completionKindFromString } from 'vs/editor/common/modes'; import { Position } from 'vs/editor/common/core/position'; import * as aria from 'vs/base/browser/ui/aria/aria'; import { IDebugSession, IConfig, IThread, IRawModelUpdate, IDebugService, IRawStoppedDetails, State, LoadedSourceEvent, IFunctionBreakpoint, IExceptionBreakpoint, IBreakpoint, IExceptionInfo, AdapterEndEvent, IDebugger, VIEWLET_ID, IDebugConfiguration, IReplElement, IStackFrame, IExpression, IReplElementSource } from 'vs/workbench/contrib/debug/common/debug'; @@ -489,7 +489,7 @@ export class DebugSession implements IDebugSession { result.push({ label: item.label, insertText: item.text || item.label, - kind: completionKindFromLegacyString(item.type), + kind: completionKindFromString(item.type), filterText: item.start && item.length && text.substr(item.start, item.length).concat(item.label), range: Range.fromPositions(position.delta(0, -(item.length || overwriteBefore)), position) }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts index 433967a73d9bf..5aa4625c2157d 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts @@ -32,7 +32,7 @@ import { getCodeActions } from 'vs/editor/contrib/codeAction/codeAction'; import { getWorkspaceSymbols } from 'vs/workbench/contrib/search/common/search'; import { rename } from 'vs/editor/contrib/rename/rename'; import { provideSignatureHelp } from 'vs/editor/contrib/parameterHints/provideSignatureHelp'; -import { provideSuggestionItems } from 'vs/editor/contrib/suggest/suggest'; +import { provideSuggestionItems, CompletionOptions } from 'vs/editor/contrib/suggest/suggest'; import { getDocumentFormattingEdits, getDocumentRangeFormattingEdits, getOnTypeFormattingEdits, FormatMode } from 'vs/editor/contrib/format/format'; import { getLinks } from 'vs/editor/contrib/links/getLinks'; import { MainContext, ExtHostContext } from 'vs/workbench/api/node/extHost.protocol'; @@ -828,7 +828,7 @@ suite('ExtHostLanguageFeatures', function () { }, [])); await rpcProtocol.sync(); - const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none'); + const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set().add(modes.CompletionItemKind.Snippet))); assert.equal(value.length, 1); assert.equal(value[0].completion.insertText, 'testing2'); }); @@ -848,7 +848,7 @@ suite('ExtHostLanguageFeatures', function () { }, [])); await rpcProtocol.sync(); - const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none'); + const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set().add(modes.CompletionItemKind.Snippet))); assert.equal(value.length, 1); assert.equal(value[0].completion.insertText, 'weak-selector'); }); @@ -868,7 +868,7 @@ suite('ExtHostLanguageFeatures', function () { }, [])); await rpcProtocol.sync(); - const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none'); + const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set().add(modes.CompletionItemKind.Snippet))); assert.equal(value.length, 2); assert.equal(value[0].completion.insertText, 'strong-1'); // sort by label assert.equal(value[1].completion.insertText, 'strong-2'); @@ -890,7 +890,7 @@ suite('ExtHostLanguageFeatures', function () { await rpcProtocol.sync(); - const value = await provideSuggestionItems(model, new EditorPosition(1, 1), 'none'); + const value = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set().add(modes.CompletionItemKind.Snippet))); assert.equal(value[0].container.incomplete, undefined); }); @@ -903,7 +903,7 @@ suite('ExtHostLanguageFeatures', function () { }, [])); await rpcProtocol.sync(); - provideSuggestionItems(model, new EditorPosition(1, 1), 'none').then(value => { + provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set().add(modes.CompletionItemKind.Snippet))).then(value => { assert.equal(value[0].container.incomplete, true); }); });