Skip to content

Commit

Permalink
Added grand scope (#2130)
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
AndreasArvidsson authored Dec 18, 2023
1 parent 91391aa commit 8f37186
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/cheatsheet/sections/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_modifiers():
"extendThroughStartOf",
"extendThroughEndOf",
"every",
"ancestor",
"first",
"last",
"previous",
Expand Down Expand Up @@ -101,6 +102,16 @@ def get_modifiers():
},
],
},
{
"id": "ancestor",
"type": "modifier",
"variations": [
{
"spokenForm": f"{complex_modifiers['ancestor']} <scope>",
"description": "Grandparent containing instance of <scope>",
},
],
},
{
"id": "relativeScope",
"type": "modifier",
Expand Down
18 changes: 17 additions & 1 deletion src/modifiers/simple_scope_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@
)
def cursorless_simple_scope_modifier(m) -> dict[str, Any]:
"""Containing scope, every scope, etc"""
if hasattr(m, "cursorless_simple_scope_modifier"):
modifier = m.cursorless_simple_scope_modifier

if modifier == "every":
return {
"type": "everyScope",
"scopeType": m.cursorless_scope_type,
}

if modifier == "ancestor":
return {
"type": "containingScope",
"scopeType": m.cursorless_scope_type,
"ancestorIndex": 1,
}

return {
"type": "everyScope" if m[0] == "every" else "containingScope",
"type": "containingScope",
"scopeType": m.cursorless_scope_type,
}
2 changes: 1 addition & 1 deletion src/spoken_forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"its": "inferPreviousMark",
"visible": "visible"
},
"simple_scope_modifier": { "every": "every" },
"simple_scope_modifier": { "every": "every", "grand": "ancestor" },
"interior_modifier": {
"inside": "interiorOnly"
},
Expand Down

0 comments on commit 8f37186

Please sign in to comment.