diff --git a/src/apps/cursorless-vscode-e2e/suite/keyboard/basic.test.ts b/src/apps/cursorless-vscode-e2e/suite/keyboard/basic.test.ts index 9a3b8a5365..78a34116e0 100644 --- a/src/apps/cursorless-vscode-e2e/suite/keyboard/basic.test.ts +++ b/src/apps/cursorless-vscode-e2e/suite/keyboard/basic.test.ts @@ -6,8 +6,14 @@ import { endToEndTestSetup, sleepWithBackoff } from "../../endToEndTestSetup"; suite("Basic keyboard test", async function () { endToEndTestSetup(this); + this.afterEach(async () => { + await vscode.commands.executeCommand("cursorless.keyboard.modal.modeOff"); + }); + test("Don't take keyboard control on startup", () => checkKeyboardStartup()); test("Basic keyboard test", () => basic()); + test("Check that entering and leaving mode is no-op", () => + enterAndLeaveIsNoOp()); }); async function checkKeyboardStartup() { @@ -48,6 +54,21 @@ async function basic() { assert.equal(editor.document.getText().trim(), "a"); } +async function enterAndLeaveIsNoOp() { + const editor = await openNewEditor("hello"); + + const originalSelection = new vscode.Selection(0, 0, 0, 0); + editor.selection = originalSelection; + + await vscode.commands.executeCommand("cursorless.keyboard.modal.modeOn"); + + assert.isTrue(editor.selection.isEqual(originalSelection)); + + await vscode.commands.executeCommand("cursorless.keyboard.modal.modeOff"); + + assert.isTrue(editor.selection.isEqual(originalSelection)); +} + async function typeText(text: string) { for (const char of text) { vscode.commands.executeCommand("type", { text: char }); diff --git a/src/keyboard/KeyboardCommandsTargeted.ts b/src/keyboard/KeyboardCommandsTargeted.ts index 4e9e6b3faa..938ef7c238 100644 --- a/src/keyboard/KeyboardCommandsTargeted.ts +++ b/src/keyboard/KeyboardCommandsTargeted.ts @@ -247,7 +247,7 @@ export default class KeyboardCommandsTargeted { targetSelection = () => executeCursorlessCommand({ action: { - name: "setSelection", + name: "highlight", }, targets: [ { @@ -255,6 +255,7 @@ export default class KeyboardCommandsTargeted { mark: { type: "cursor", }, + modifiers: [{ type: "toRawSelection" }], }, ], });