diff --git a/src/cheatsheet/sections/modifiers.py b/src/cheatsheet/sections/modifiers.py index 576edc4721..55d3f396a3 100644 --- a/src/cheatsheet/sections/modifiers.py +++ b/src/cheatsheet/sections/modifiers.py @@ -22,6 +22,7 @@ def get_modifiers(): "extendThroughStartOf", "extendThroughEndOf", "every", + "ancestor", "first", "last", "previous", @@ -101,6 +102,16 @@ def get_modifiers(): }, ], }, + { + "id": "ancestor", + "type": "modifier", + "variations": [ + { + "spokenForm": f"{complex_modifiers['ancestor']} ", + "description": "Grandparent containing instance of ", + }, + ], + }, { "id": "relativeScope", "type": "modifier", diff --git a/src/modifiers/simple_scope_modifier.py b/src/modifiers/simple_scope_modifier.py index 7725623304..5d51ba8a4e 100644 --- a/src/modifiers/simple_scope_modifier.py +++ b/src/modifiers/simple_scope_modifier.py @@ -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, } diff --git a/src/spoken_forms.json b/src/spoken_forms.json index 8392060dbd..6b3588405d 100644 --- a/src/spoken_forms.json +++ b/src/spoken_forms.json @@ -81,7 +81,7 @@ "its": "inferPreviousMark", "visible": "visible" }, - "simple_scope_modifier": { "every": "every" }, + "simple_scope_modifier": { "every": "every", "grand": "ancestor" }, "interior_modifier": { "inside": "interiorOnly" },