Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cursorless-talon/src/modifiers/simple_scope_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@mod.capture(
rule=(
"[{user.cursorless_every_scope_modifier} | {user.cursorless_ancestor_scope_modifier}] "
"[{user.cursorless_every_scope_modifier} | {user.cursorless_ancestor_scope_modifier}+] "
"<user.cursorless_scope_type>"
),
)
Expand All @@ -40,7 +40,7 @@ def cursorless_simple_scope_modifier(m) -> dict[str, Any]:
return {
"type": "containingScope",
"scopeType": m.cursorless_scope_type,
"ancestorIndex": 1,
"ancestorIndex": len(m.cursorless_ancestor_scope_modifier_list),
}

if settings.get("user.private_cursorless_use_preferred_scope"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
languageId: javascript
command:
version: 7
spokenForm: change grand grand state
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: statement}
ancestorIndex: 2
usePrePhraseSnapshot: false
initialState:
documentContents: |-
class MyClass {
myFunk() {
console.log("");
}
}
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 8}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ export class PrimitiveTargetSpokenFormGenerator {
if (modifier.ancestorIndex == null || modifier.ancestorIndex === 0) {
return this.handleScopeType(modifier.scopeType);
}
if (modifier.ancestorIndex === 1) {
return [
return [
new Array(modifier.ancestorIndex).fill(
this.spokenFormMap.modifierExtra.ancestor,
this.handleScopeType(modifier.scopeType),
];
}
throw new NoSpokenFormError(
`Modifier '${modifier.type}' with ancestor index ${modifier.ancestorIndex}`,
);
),
this.handleScopeType(modifier.scopeType),
];

case "everyScope":
return [
Expand Down
6 changes: 5 additions & 1 deletion packages/cursorless-org-docs/src/docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ The modifier `"grand"` can be used to select the parent of the containing syntac
- `"take grand statement air"`
- `"take grand funk air"`

For example, the command `"take grand statement [blue] air"` will select that parent statement of the statement containing the token with a blue hat over the letter 'a'.
For example, the command `"take grand statement [blue] air"` will select the parent statement of the statement containing the token with a blue hat over the letter 'a'.
Copy link
Member

@phillco phillco Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed a bit about having unique terms for 1st/2nd/3rd parent as shortcuts, but noone came obviously to mind. There is also the existing awkwardness of the second parent most likely being something like "grandparent" but that is ambiguous with the generic parent command. Historically, parent wasn't chosen as "grand" because it is long and awkward to say and we assumed most people are just looking for the first or second parent.


You can also repeat `"grand"` multiple times.

For example, the command `"take grand grand statement [blue] air"` will select the parent statement of the parent statement of the statement containing the token with a blue hat over the letter 'a'.

##### Sub-token modifiers

Expand Down
Loading