Skip to content

Commit 6820a21

Browse files
committed
Basic multiple relative scope grammar
1 parent 21b9726 commit 6820a21

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cursorless-talon/src/modifiers/modifiers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def cursorless_simple_modifier(m) -> dict[str, str]:
4141
"<user.cursorless_containing_scope>", # funk, state, class
4242
"<user.cursorless_ordinal_scope>", # first past second word
4343
"<user.cursorless_relative_scope>", # next funk
44+
"<user.cursorless_scope_count>", # two funks
4445
"<user.cursorless_surrounding_pair>", # matching/pair [curly, round]
4546
]
4647

cursorless-talon/src/modifiers/relative_scope.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
mod = Module()
66

77

8-
@mod.capture(rule="(previous | next) <user.cursorless_scope_type>")
8+
@mod.capture(rule="(previous | next) [<number_small>] <user.cursorless_scope_type>")
99
def cursorless_relative_scope(m) -> dict[str, Any]:
1010
"""Previous/next scope"""
1111
return {
1212
"type": "relativeScope",
1313
"scopeType": m.cursorless_scope_type,
1414
"offset": 1,
15-
"length": 1,
15+
"length": getattr(m, "number_small", 1),
1616
"direction": "backward" if m[0] == "previous" else "forward",
1717
}
18+
19+
20+
@mod.capture(rule="<number_small> <user.cursorless_scope_type> [backward]")
21+
def cursorless_scope_count(m) -> dict[str, Any]:
22+
"""Previous/next scope"""
23+
return {
24+
"type": "relativeScope",
25+
"scopeType": m.cursorless_scope_type,
26+
"offset": 0,
27+
"length": m.number_small,
28+
"direction": "backward" if m[-1] == "backward" else "forward",
29+
}

0 commit comments

Comments
 (0)