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

fix #36491

上级 333a2285
...@@ -259,17 +259,14 @@ export class SuggestModel implements IDisposable { ...@@ -259,17 +259,14 @@ export class SuggestModel implements IDisposable {
this._currentPosition = this._editor.getPosition(); this._currentPosition = this._editor.getPosition();
if (!e.selection.isEmpty() if (!e.selection.isEmpty()
|| e.source !== 'keyboard'
|| e.reason !== CursorChangeReason.NotSet || e.reason !== CursorChangeReason.NotSet
|| (e.source !== 'keyboard' && e.source !== 'deleteLeft')
) { ) {
// Early exit if nothing needs to be done!
if (this._state === State.Idle) { // Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
// Early exit if nothing needs to be done! if (this._state !== State.Idle) {
// Leave some form of early exit check here if you wish to continue being a cursor position change listener ;) this.cancel();
return;
} }
this.cancel();
return; return;
} }
......
...@@ -23,6 +23,7 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil ...@@ -23,6 +23,7 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import { EditOperation } from 'vs/editor/common/core/editOperation'; import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
function createMockEditor(model: Model): TestCodeEditor { function createMockEditor(model: Model): TestCodeEditor {
const contextKeyService = new MockContextKeyService(); const contextKeyService = new MockContextKeyService();
...@@ -534,4 +535,33 @@ suite('SuggestModel - TriggerAndCancelOracle', function () { ...@@ -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.
先完成此消息的编辑!
想要评论请 注册