Skip to content

Commit 7a51850

Browse files
authored
keyboard: Use parser for key sequences (#2051)
## 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) (keeping this somewhat under wraps while we experiment - [x] I have not broken the cheatsheet - [-] Refactor delete mapping to just issue token for delete action - [x] Extract partial parameters - [-] Add railroad to docs?
1 parent 4844109 commit 7a51850

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1955
-256
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trim_trailing_whitespace = false
2828
[Makefile]
2929
indent_style = tab
3030

31-
[**/vendor/**]
31+
[**/{vendor,generated}/**]
3232
charset = unset
3333
end_of_line = unset
3434
indent_size = unset

.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,10 @@
7878
}
7979
}
8080
},
81-
"ignorePatterns": ["**/vendor/**/*.ts", "**/vendor/**/*.js", "**/out/**"]
81+
"ignorePatterns": [
82+
"**/vendor/**/*.ts",
83+
"**/vendor/**/*.js",
84+
"**/out/**",
85+
"**/generated/**"
86+
]
8287
}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ repos:
4040
# tests use strings with trailing white space to represent the final
4141
# document contents. For example
4242
# packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/ruby/changeCondition.yml
43-
exclude: ^packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/.*/[^/]*\.yml$
43+
exclude: ^packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/.*/[^/]*\.yml$|/generated/|^patches/
4444
- repo: local
4545
hooks:
4646
- id: eslint

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/vendor
2+
**/generated
23

34
# We use our own format for our recorded yaml tests to keep them compact
45
/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/**/*.yml

.vscode/tasks.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"type": "npm",
2727
"script": "esbuild",
2828
"path": "packages/cursorless-vscode",
29+
"dependsOn": ["Generate grammar"],
2930
"presentation": {
3031
"reveal": "silent"
3132
},
@@ -61,6 +62,16 @@
6162
},
6263
"group": "build"
6364
},
65+
{
66+
"label": "Generate grammar",
67+
"type": "npm",
68+
"script": "generate-grammar",
69+
"path": "packages/cursorless-vscode",
70+
"presentation": {
71+
"reveal": "silent"
72+
},
73+
"group": "build"
74+
},
6475
{
6576
"label": "Ensure test subset file exists",
6677
"type": "npm",

docs/user/experimental/keyboard/modal.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The above allows you to press `ctrl-c` to switch to Cursorless mode, `escape` to
4242
To bind keys that do not have modifiers (eg just pressing `a`), add entries like the following to your [VSCode `settings.json`](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson) (or edit these settings in the VSCode settings gui by saying `"cursorless settings"`):
4343

4444
```json
45-
"cursorless.experimental.keyboard.modal.keybindings.scopes": {
45+
"cursorless.experimental.keyboard.modal.keybindings.scope": {
4646
"i": "line",
4747
"p": "paragraph",
4848
";": "statement",
@@ -60,7 +60,7 @@ To bind keys that do not have modifiers (eg just pressing `a`), add entries like
6060
"sa": "argumentOrParameter",
6161
"sl": "url",
6262
},
63-
"cursorless.experimental.keyboard.modal.keybindings.actions": {
63+
"cursorless.experimental.keyboard.modal.keybindings.action": {
6464
"t": "setSelection",
6565
"h": "setSelectionBefore",
6666
"l": "setSelectionAfter",
@@ -81,13 +81,13 @@ To bind keys that do not have modifiers (eg just pressing `a`), add entries like
8181
"ap": "pasteFromClipboard",
8282
"ad": "followLink"
8383
},
84-
"cursorless.experimental.keyboard.modal.keybindings.colors": {
84+
"cursorless.experimental.keyboard.modal.keybindings.color": {
8585
"d": "default",
8686
"b": "blue",
8787
"g": "yellow",
8888
"r": "red"
8989
},
90-
"cursorless.experimental.keyboard.modal.keybindings.shapes": {
90+
"cursorless.experimental.keyboard.modal.keybindings.shape": {
9191
"x": "ex",
9292
"f": "fox",
9393
"q": "frame",
@@ -97,7 +97,7 @@ To bind keys that do not have modifiers (eg just pressing `a`), add entries like
9797
"z": "bolt",
9898
"w": "crosshairs"
9999
},
100-
"cursorless.experimental.keyboard.modal.keybindings.vscodeCommands": {
100+
"cursorless.experimental.keyboard.modal.keybindings.vscodeCommand": {
101101
// For simple commands, just use the command name
102102
// "aa": "workbench.action.editor.changeLanguageMode",
103103

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
},
4545
"pnpm": {
4646
"patchedDependencies": {
47-
"@docusaurus/[email protected]": "patches/@[email protected]"
47+
"@docusaurus/[email protected]": "patches/@[email protected]",
48+
"@types/[email protected]": "patches/@[email protected]",
49+
4850
},
4951
"peerDependencyRules": {
5052
"ignoreMissing": [

packages/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/mocha": "^10.0.3",
2626
"@types/sinon": "^10.0.2",
2727
"cross-spawn": "7.0.3",
28+
"fast-check": "3.12.0",
2829
"js-yaml": "^4.1.0",
2930
"mocha": "^10.2.0",
3031
"sinon": "^11.1.1"

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export * from "./types/GeneralizedRange";
5656
export * from "./types/RangeOffsets";
5757
export * from "./util/omitByDeep";
5858
export * from "./util/range";
59+
export * from "./util/uniqWithHash";
5960
export * from "./testUtil/isTesting";
6061
export * from "./testUtil/testConstants";
6162
export * from "./testUtil/getFixturePaths";

packages/common/src/util/CompositeKeyMap.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ export class CompositeKeyMap<K, V> {
3535
delete this.map[this.hash(key)];
3636
return this;
3737
}
38+
39+
clear(): this {
40+
this.map = {};
41+
return this;
42+
}
3843
}

0 commit comments

Comments
 (0)