提交 e8a40842 编写于 作者: J Johannes Rieken

fix #36491

上级 333a2285
......@@ -259,17 +259,14 @@ export class SuggestModel implements IDisposable {
this._currentPosition = this._editor.getPosition();
if (!e.selection.isEmpty()
|| e.source !== 'keyboard'
|| e.reason !== CursorChangeReason.NotSet
|| (e.source !== 'keyboard' && e.source !== 'deleteLeft')
) {
if (this._state === State.Idle) {
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
return;
// Early exit if nothing needs to be done!
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
if (this._state !== State.Idle) {
this.cancel();
}
this.cancel();
return;
}
......
......@@ -23,6 +23,7 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Range } from 'vs/editor/common/core/range';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
function createMockEditor(model: Model): TestCodeEditor {
const contextKeyService = new MockContextKeyService();
......@@ -534,4 +535,33 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
});
});
});
test('Backspace should not always cancel code completion, #36491', function () {
disposables.push(SuggestRegistry.register({ scheme: 'test' }, alwaysSomethingSupport));
return withOracle(async (model, editor) => {
await assertEvent(model.onDidSuggest, () => {
editor.setPosition({ lineNumber: 1, column: 4 });
editor.trigger('keyboard', Handler.Type, { text: 'd' });
}, event => {
assert.equal(event.auto, true);
assert.equal(event.completionModel.items.length, 1);
const [first] = event.completionModel.items;
assert.equal(first.support, alwaysSomethingSupport);
});
await assertEvent(model.onDidSuggest, () => {
CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null);
}, event => {
assert.equal(event.auto, true);
assert.equal(event.completionModel.items.length, 1);
const [first] = event.completionModel.items;
assert.equal(first.support, alwaysSomethingSupport);
});
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册