This commit is contained in:
Johannes Rieken 2021-07-02 11:51:41 +02:00
parent 8e16690b35
commit 0984071fe0
No known key found for this signature in database
GPG key ID: 96634B5AF12F8798
2 changed files with 60 additions and 0 deletions

View file

@ -235,6 +235,11 @@ export class SuggestModel implements IDisposable {
return;
}
if (LineContext.shouldAutoTrigger(this._editor)) {
// don't trigger by trigger characters when this is a case for quick suggest
return;
}
if (!text) {
// came here from the compositionEnd-event
const position = this._editor.getPosition()!;

View file

@ -864,4 +864,59 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
});
});
});
test('registerCompletionItemProvider with letters as trigger characters block other completion items to show up #127815', async function () {
disposables.push(CompletionProviderRegistry.register({ scheme: 'test' }, {
provideCompletionItems(doc, pos) {
return {
suggestions: [{
kind: CompletionItemKind.Class,
label: 'AAAA',
insertText: 'WordTriggerA',
range: new Range(pos.lineNumber, pos.column, pos.lineNumber, pos.column)
}],
};
}
}));
disposables.push(CompletionProviderRegistry.register({ scheme: 'test' }, {
triggerCharacters: ['a', '.'],
provideCompletionItems(doc, pos) {
return {
suggestions: [{
kind: CompletionItemKind.Class,
label: 'AAAA',
insertText: 'AutoTriggerA',
range: new Range(pos.lineNumber, pos.column, pos.lineNumber, pos.column)
}],
};
},
}));
return withOracle(async (model, editor) => {
await assertEvent(model.onDidSuggest, () => {
editor.setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
editor.trigger('keyboard', Handler.Type, { text: '.' });
}, event => {
assert.strictEqual(event.auto, true);
assert.strictEqual(event.completionModel.items.length, 1);
});
editor.getModel().setValue('');
await assertEvent(model.onDidSuggest, () => {
editor.setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
editor.trigger('keyboard', Handler.Type, { text: 'a' });
}, event => {
assert.strictEqual(event.auto, true);
assert.strictEqual(event.completionModel.items.length, 2);
});
});
});
});