Skip to content

Commit 2fb5d44

Browse files
authored
Don't clobber keyboard target after executing action (#2203)
## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent b9aed38 commit 2fb5d44

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/cursorless-vscode-e2e/src/suite/keyboard/basic.vscode.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ const testCases: TestCase[] = [
6969
keySequence: ["da", "aw", "wp"],
7070
finalContent: "(a)",
7171
},
72+
{
73+
name: "preserve keyboard target",
74+
initialContent: "a\n",
75+
// round wrap air; round wrap <keyboard target>
76+
keySequence: ["da", "aw", "wp", "aw", "wp"],
77+
finalContent: "((a))\n",
78+
},
7279
];
7380

7481
suite("Basic keyboard test", async function () {

packages/cursorless-vscode/src/keyboard/KeyboardCommandsTargeted.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ export default class KeyboardCommandsTargeted {
261261
// For some Cursorless actions, it is more convenient if we automatically
262262
// exit modal mode
263263
await this.modal.modeOff();
264+
} else {
265+
// If we're not exiting cursorless mode, preserve the keyboard mark
266+
// FIXME: Better to just not clobber the keyboard mark on each action?
267+
await executeCursorlessCommand({
268+
name: "private.setKeyboardTarget",
269+
target: {
270+
type: "primitive",
271+
mark: {
272+
type: "that",
273+
},
274+
},
275+
});
264276
}
265277

266278
return returnValue;

0 commit comments

Comments
 (0)