mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 12:20:29 -04:00
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
109 lines
3.7 KiB
TypeScript
109 lines
3.7 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import * as assert from 'assert';
|
|
import { URI } from 'vs/base/common/uri';
|
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
|
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';
|
|
|
|
|
|
suite('Suggest', function () {
|
|
|
|
let model: TextModel;
|
|
let registration: IDisposable;
|
|
|
|
setup(function () {
|
|
|
|
model = TextModel.createFromString('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
|
|
registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, {
|
|
provideCompletionItems(_doc, pos) {
|
|
return {
|
|
incomplete: false,
|
|
suggestions: [{
|
|
label: 'aaa',
|
|
kind: CompletionItemKind.Snippet,
|
|
insertText: 'aaa',
|
|
range: Range.fromPositions(pos)
|
|
}, {
|
|
label: 'zzz',
|
|
kind: CompletionItemKind.Snippet,
|
|
insertText: 'zzz',
|
|
range: Range.fromPositions(pos)
|
|
}, {
|
|
label: 'fff',
|
|
kind: CompletionItemKind.Property,
|
|
insertText: 'fff',
|
|
range: Range.fromPositions(pos)
|
|
}]
|
|
};
|
|
}
|
|
});
|
|
});
|
|
|
|
teardown(() => {
|
|
registration.dispose();
|
|
model.dispose();
|
|
});
|
|
|
|
test('sort - snippet inline', async function () {
|
|
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');
|
|
assert.equal(items[2].completion.label, 'zzz');
|
|
});
|
|
|
|
test('sort - snippet top', async function () {
|
|
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');
|
|
assert.equal(items[2].completion.label, 'fff');
|
|
});
|
|
|
|
test('sort - snippet bottom', async function () {
|
|
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');
|
|
assert.equal(items[2].completion.label, 'zzz');
|
|
});
|
|
|
|
test('sort - snippet none', async function () {
|
|
const items = await provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(undefined, new Set<CompletionItemKind>().add(CompletionItemKind.Snippet)));
|
|
assert.equal(items.length, 1);
|
|
assert.equal(items[0].completion.label, 'fff');
|
|
});
|
|
|
|
test('only from', function () {
|
|
|
|
const foo: any = {
|
|
triggerCharacters: [],
|
|
provideCompletionItems() {
|
|
return {
|
|
currentWord: '',
|
|
incomplete: false,
|
|
suggestions: [{
|
|
label: 'jjj',
|
|
type: 'property',
|
|
insertText: 'jjj'
|
|
}]
|
|
};
|
|
}
|
|
};
|
|
const registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, foo);
|
|
|
|
provideSuggestionItems(model, new Position(1, 1), new CompletionOptions(undefined, undefined, new Set<CompletionItemProvider>().add(foo))).then(items => {
|
|
registration.dispose();
|
|
|
|
assert.equal(items.length, 1);
|
|
assert.ok(items[0].provider === foo);
|
|
});
|
|
});
|
|
});
|