Skip to content

Commit

Permalink
Stop using backspace for delete
Browse files Browse the repository at this point in the history
This broke when we reworked our keyboard actions setup. It's also not properly integrated with new keyboard parser. If we wanted to support special keys like `backspace` with our keyboard parser, we should define a VSCode command that sends a keyboard token to our parser, and map `backspace` to that
  • Loading branch information
pokey committed Jan 25, 2024
1 parent 08abb7f commit c407398
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
11 changes: 3 additions & 8 deletions docs/user/experimental/keyboard/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ Paste the following into your [VSCode `keybindings.json`](https://code.visualstu
"key": "escape",
"command": "cursorless.keyboard.escape",
"when": "cursorless.keyboard.listening && editorTextFocus && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
},
{
"key": "backspace",
"command": "cursorless.keyboard.targeted.runActionOnTarget",
"args": "remove",
"when": "cursorless.keyboard.modal.mode && editorTextFocus"
}
```

Any keybindings that use modifier keys should go in `keybindings.json` as well, with a `"when": "cursorless.keyboard.modal.mode` clause.

The above allows you to press `ctrl-c` to switch to Cursorless mode, `escape` to exit Cursorless mode, and `backspace` to issue the delete action while in Cursorless mode.
The above allows you to press `ctrl-c` to switch to Cursorless mode and `escape` to exit Cursorless mode.

If you're already in Cursorless mode, pressing `ctrl-c` again will target the current selection, which is useful if you have moved the cursor using your mouse while in Cursorless mode, and want to target your new cursor position.

Expand Down Expand Up @@ -86,7 +80,8 @@ To bind keys that do not have modifiers (eg just pressing `a`), add entries like
"ac": "copyToClipboard",
"ax": "cutToClipboard",
"ap": "pasteFromClipboard",
"ad": "followLink"
"ad": "followLink",
"aw": "remove",
},
"cursorless.experimental.keyboard.modal.keybindings.color": {
"d": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const testCases: TestCase[] = [
name: "every",
initialContent: "a a\nb b\n",
// change every token air
keySequence: ["da", "x", "st", "c"],
keySequence: ["da", "*", "st", "c"],
finalContent: " \nb b\n",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,25 @@
},
"cursorless.experimental.keyboard.modal.keybindings.action": {
"at": "setSelection",
"ah": { "actionId": "setSelectionBefore", "exitCursorlessMode": true },
"al": { "actionId": "setSelectionAfter", "exitCursorlessMode": true },
"aO": { "actionId": "editNewLineBefore", "exitCursorlessMode": true },
"ah": "setSelectionBefore",
"al": "setSelectionAfter",
"ai": { "actionId": "editNewLineBefore", "exitCursorlessMode": true },
"ao": { "actionId": "editNewLineAfter", "exitCursorlessMode": true },
"k": "insertCopyBefore",
"j": "insertCopyAfter",
"ak": "insertCopyBefore",
"aj": "insertCopyAfter",
"au": "replaceWithTarget",
"am": "moveToTarget",
"c": { "actionId": "clearAndSetSelection", "exitCursorlessMode": true },
"as": "swapTargets",
"af": "foldRegion",
"ak": "insertEmptyLineBefore",
"aj": "insertEmptyLineAfter",
"ai": "insertEmptyLinesAround",
"aI": "insertEmptyLineBefore",
"aO": "insertEmptyLineAfter",
"aU": "insertEmptyLinesAround",
"ac": "copyToClipboard",
"ax": "cutToClipboard",
"ap": "pasteFromClipboard",
"ad": "followLink",
"x": "remove",
"aw": "wrap"
},
"cursorless.experimental.keyboard.modal.keybindings.color": {
Expand Down Expand Up @@ -66,7 +67,7 @@
},
"cursorless.experimental.keyboard.modal.keybindings.modifier": {
"n": "nextPrev",
"x": "every"
"*": "every"
},
"cursorless.experimental.keyboard.modal.keybindings.vscodeCommand": {
"va": "editor.action.addCommentLine",
Expand Down

0 comments on commit c407398

Please sign in to comment.