|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 | import * as assert from 'assert';
|
6 | 6 | import { Event } from 'vs/base/common/event';
|
7 |
| -import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; |
| 7 | +import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle'; |
8 | 8 | import { URI } from 'vs/base/common/uri';
|
9 | 9 | import { mock } from 'vs/base/test/common/mock';
|
10 | 10 | import { CoreEditingCommands } from 'vs/editor/browser/coreCommands';
|
@@ -38,6 +38,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
38 | 38 | import { LanguageFeaturesService } from 'vs/editor/common/services/languageFeaturesService';
|
39 | 39 | import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
40 | 40 | import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
| 41 | +import { getSnippetSuggestSupport, setSnippetSuggestSupport } from 'vs/editor/contrib/suggest/browser/suggest'; |
41 | 42 |
|
42 | 43 |
|
43 | 44 | function createMockEditor(model: TextModel, languageFeaturesService: ILanguageFeaturesService): ITestCodeEditor {
|
@@ -1124,4 +1125,72 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
|
1124 | 1125 | });
|
1125 | 1126 | });
|
1126 | 1127 | });
|
| 1128 | + |
| 1129 | + test('Snippets gone from IntelliSense #173244', function () { |
| 1130 | + |
| 1131 | + const snippetProvider: CompletionItemProvider = { |
| 1132 | + provideCompletionItems(doc, pos, ctx) { |
| 1133 | + return { |
| 1134 | + suggestions: [{ |
| 1135 | + label: 'log', |
| 1136 | + kind: CompletionItemKind.Snippet, |
| 1137 | + insertText: 'log', |
| 1138 | + range: getDefaultSuggestRange(doc, pos) |
| 1139 | + }] |
| 1140 | + }; |
| 1141 | + } |
| 1142 | + }; |
| 1143 | + const old = setSnippetSuggestSupport(snippetProvider); |
| 1144 | + |
| 1145 | + disposables.add(toDisposable(() => { |
| 1146 | + if (getSnippetSuggestSupport() === snippetProvider) { |
| 1147 | + setSnippetSuggestSupport(old); |
| 1148 | + } |
| 1149 | + })); |
| 1150 | + |
| 1151 | + disposables.add(registry.register({ scheme: 'test' }, { |
| 1152 | + triggerCharacters: ['.'], |
| 1153 | + provideCompletionItems(doc, pos, ctx) { |
| 1154 | + return { |
| 1155 | + suggestions: [{ |
| 1156 | + label: 'locals', |
| 1157 | + kind: CompletionItemKind.Property, |
| 1158 | + insertText: 'locals', |
| 1159 | + range: getDefaultSuggestRange(doc, pos) |
| 1160 | + }], |
| 1161 | + incomplete: true |
| 1162 | + }; |
| 1163 | + }, |
| 1164 | + })); |
| 1165 | + |
| 1166 | + return withOracle(async function (model, editor) { |
| 1167 | + |
| 1168 | + await assertEvent(model.onDidSuggest, () => { |
| 1169 | + editor.setValue(''); |
| 1170 | + editor.setSelection(new Selection(1, 1, 1, 1)); |
| 1171 | + editor.trigger('keyboard', Handler.Type, { text: 'l' }); |
| 1172 | + |
| 1173 | + |
| 1174 | + }, event => { |
| 1175 | + assert.strictEqual(event.triggerOptions.auto, true); |
| 1176 | + assert.strictEqual(event.triggerOptions.triggerCharacter, undefined); |
| 1177 | + assert.strictEqual(event.triggerOptions.triggerKind, undefined); |
| 1178 | + assert.strictEqual(event.completionModel.items.length, 2); |
| 1179 | + assert.strictEqual(event.completionModel.items[0].textLabel, 'locals'); |
| 1180 | + assert.strictEqual(event.completionModel.items[1].textLabel, 'log'); |
| 1181 | + }); |
| 1182 | + |
| 1183 | + await assertEvent(model.onDidSuggest, () => { |
| 1184 | + editor.trigger('keyboard', Handler.Type, { text: 'o' }); |
| 1185 | + |
| 1186 | + }, event => { |
| 1187 | + assert.strictEqual(event.triggerOptions.triggerKind, CompletionTriggerKind.TriggerForIncompleteCompletions); |
| 1188 | + assert.strictEqual(event.triggerOptions.auto, true); |
| 1189 | + assert.strictEqual(event.completionModel.items.length, 2); |
| 1190 | + assert.strictEqual(event.completionModel.items[0].textLabel, 'locals'); |
| 1191 | + assert.strictEqual(event.completionModel.items[1].textLabel, 'log'); |
| 1192 | + }); |
| 1193 | + |
| 1194 | + }); |
| 1195 | + }); |
1127 | 1196 | });
|
0 commit comments