Skip to content

Commit cbc85e8

Browse files
authored
Add some types to keyboard grammar (#2435)
## Checklist - [-] 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 3493ca2 commit cbc85e8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/cursorless-vscode/src/keyboard/grammar/generated/grammar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ declare var digit: any;
2323
import { capture, UNUSED as _, argPositions } from "@cursorless/cursorless-engine"
2424
import { command } from "../command"
2525
import { keyboardLexer } from "../keyboardLexer";
26+
import { RelativeScopeModifier } from "@cursorless/common";
2627

2728
const { $0, $1, $2 } = argPositions;
2829

@@ -93,7 +94,7 @@ const grammar: Grammar = {
9394
{"name": "modifier$ebnf$2", "symbols": ["number"], "postprocess": id},
9495
{"name": "modifier$ebnf$2", "symbols": [], "postprocess": () => null},
9596
{"name": "modifier", "symbols": ["modifier$ebnf$1", (keyboardLexer.has("nextPrev") ? {type: "nextPrev"} : nextPrev), "modifier$ebnf$2", "scopeType"], "postprocess":
96-
([offset, _, length, scopeType]) => ({
97+
([offset, _, length, scopeType]): RelativeScopeModifier => ({
9798
type: "relativeScope",
9899
offset: offset?.number ?? 1,
99100
direction: offset?.direction ?? "forward",
@@ -102,7 +103,7 @@ const grammar: Grammar = {
102103
})
103104
},
104105
{"name": "modifier", "symbols": ["offset", "scopeType"], "postprocess":
105-
([offset, scopeType]) => ({
106+
([offset, scopeType]): RelativeScopeModifier => ({
106107
type: "relativeScope",
107108
offset: 0,
108109
direction: offset?.direction ?? "forward",

packages/cursorless-vscode/src/keyboard/grammar/grammar.ne

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { capture, UNUSED as _, argPositions } from "@cursorless/cursorless-engine"
44
import { command } from "../command"
55
import { keyboardLexer } from "../keyboardLexer";
6+
import { RelativeScopeModifier } from "@cursorless/common";
67

78
const { $0, $1, $2 } = argPositions;
89
%}
@@ -68,7 +69,7 @@ modifier -> %every scopeType {% capture({ type: "everyScope", scopeType: $1 }) %
6869
# "[third] next [two] funks"
6970
# "[third] previous [two] funks"
7071
modifier -> offset:? %nextPrev number:? scopeType {%
71-
([offset, _, length, scopeType]) => ({
72+
([offset, _, length, scopeType]): RelativeScopeModifier => ({
7273
type: "relativeScope",
7374
offset: offset?.number ?? 1,
7475
direction: offset?.direction ?? "forward",
@@ -79,7 +80,7 @@ modifier -> offset:? %nextPrev number:? scopeType {%
7980

8081
# "three funks [backward]"
8182
modifier -> offset scopeType {%
82-
([offset, scopeType]) => ({
83+
([offset, scopeType]): RelativeScopeModifier => ({
8384
type: "relativeScope",
8485
offset: 0,
8586
direction: offset?.direction ?? "forward",

0 commit comments

Comments
 (0)