Skip to content

Commit 8f37186

Browse files
Added grand scope (#2130)
`change grand statement` ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [x] 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) - [x] I have not broken the cheatsheet
1 parent 91391aa commit 8f37186

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/cheatsheet/sections/modifiers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def get_modifiers():
2222
"extendThroughStartOf",
2323
"extendThroughEndOf",
2424
"every",
25+
"ancestor",
2526
"first",
2627
"last",
2728
"previous",
@@ -101,6 +102,16 @@ def get_modifiers():
101102
},
102103
],
103104
},
105+
{
106+
"id": "ancestor",
107+
"type": "modifier",
108+
"variations": [
109+
{
110+
"spokenForm": f"{complex_modifiers['ancestor']} <scope>",
111+
"description": "Grandparent containing instance of <scope>",
112+
},
113+
],
114+
},
104115
{
105116
"id": "relativeScope",
106117
"type": "modifier",

src/modifiers/simple_scope_modifier.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,23 @@
1515
)
1616
def cursorless_simple_scope_modifier(m) -> dict[str, Any]:
1717
"""Containing scope, every scope, etc"""
18+
if hasattr(m, "cursorless_simple_scope_modifier"):
19+
modifier = m.cursorless_simple_scope_modifier
20+
21+
if modifier == "every":
22+
return {
23+
"type": "everyScope",
24+
"scopeType": m.cursorless_scope_type,
25+
}
26+
27+
if modifier == "ancestor":
28+
return {
29+
"type": "containingScope",
30+
"scopeType": m.cursorless_scope_type,
31+
"ancestorIndex": 1,
32+
}
33+
1834
return {
19-
"type": "everyScope" if m[0] == "every" else "containingScope",
35+
"type": "containingScope",
2036
"scopeType": m.cursorless_scope_type,
2137
}

src/spoken_forms.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"its": "inferPreviousMark",
8282
"visible": "visible"
8383
},
84-
"simple_scope_modifier": { "every": "every" },
84+
"simple_scope_modifier": { "every": "every", "grand": "ancestor" },
8585
"interior_modifier": {
8686
"inside": "interiorOnly"
8787
},

0 commit comments

Comments
 (0)