mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-28 05:37:48 +01:00
This commit is contained in:
@@ -635,6 +635,12 @@ export class SuggestModel implements IDisposable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctx.leadingLineContent.startsWith(this._context.leadingLineContent) && !this._context.leadingLineContent.startsWith(ctx.leadingLineContent)) {
|
||||
// e.g. happens when line prefix changes, e.g delete while suggest is showing
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (getLeadingWhitespace(ctx.leadingLineContent) !== getLeadingWhitespace(this._context.leadingLineContent)) {
|
||||
// cancel IntelliSense when line start changes
|
||||
// happens when the current word gets outdented
|
||||
|
||||
@@ -32,6 +32,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
|
||||
import { LanguageFeaturesService } from 'vs/editor/common/services/languageFeaturesService';
|
||||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { DeleteLinesAction } from 'vs/editor/contrib/linesOperations/browser/linesOperations';
|
||||
|
||||
suite('SuggestController', function () {
|
||||
|
||||
@@ -579,4 +580,38 @@ suite('SuggestController', function () {
|
||||
controller.acceptSelectedSuggestion(false, false);
|
||||
assert.strictEqual(editor.getValue(), 'for');
|
||||
});
|
||||
|
||||
test('Suggest widget gets orphaned in editor #187779', async function () {
|
||||
|
||||
disposables.add(languageFeaturesService.completionProvider.register({ scheme: 'test-ctrl' }, {
|
||||
_debugDisplayName: 'test',
|
||||
provideCompletionItems(doc, pos) {
|
||||
|
||||
const word = doc.getLineContent(pos.lineNumber);
|
||||
const range = new Range(pos.lineNumber, 1, pos.lineNumber, pos.column);
|
||||
|
||||
return {
|
||||
suggestions: [{
|
||||
kind: CompletionItemKind.Text,
|
||||
label: word,
|
||||
insertText: word,
|
||||
range
|
||||
}]
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
editor.setValue(`console.log(example.)\nconsole.log(EXAMPLE.not)`);
|
||||
editor.setSelection(new Selection(1, 21, 1, 21));
|
||||
|
||||
const p1 = Event.toPromise(controller.model.onDidSuggest);
|
||||
controller.triggerSuggest();
|
||||
|
||||
await p1;
|
||||
|
||||
const p2 = Event.toPromise(controller.model.onDidCancel);
|
||||
new DeleteLinesAction().run(null!, editor);
|
||||
|
||||
await p2;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user