Skip to content

Commit 84c06db

Browse files
AndreasArvidssonAndreas Arvidssonpre-commit-ci[bot]pokey
authored
Fixed talon warning messages (#818)
* Fixed talon warning messages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Naming / documentation tweaks * Fix circular import Co-authored-by: Andreas Arvidsson <andreas.arvidsson@redpill-linpro.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
1 parent 57ace86 commit 84c06db

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

cursorless-talon/src/modifiers/head_tail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
rule=(
1818
"{user.cursorless_head_tail_modifier} "
1919
"[<user.cursorless_interior_modifier>] "
20-
"[<user.cursorless_modifier>]"
20+
"[<user.cursorless_head_tail_swallowed_modifier>]"
2121
)
2222
)
2323
def cursorless_head_tail_modifier(m) -> dict[str, str]:
@@ -30,7 +30,7 @@ def cursorless_head_tail_modifier(m) -> dict[str, str]:
3030
pass
3131

3232
try:
33-
modifiers.append(m.cursorless_modifier)
33+
modifiers.append(m.cursorless_head_tail_swallowed_modifier)
3434
except AttributeError:
3535
pass
3636

cursorless-talon/src/modifiers/modifiers.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,39 @@ def cursorless_simple_modifier(m) -> dict[str, str]:
3030
}
3131

3232

33-
modifiers = [
34-
"<user.cursorless_position>", # before, end of
33+
# These are the modifiers that will be "swallowed" by the head/tail modifier.
34+
# For example, saying "head funk" will result in a "head" modifier that will
35+
# select past the start of the function.
36+
# Note that we don't include "inside" here, because that requires slightly
37+
# special treatment to ensure that "head inside round" swallows "inside round"
38+
# rather than just "inside".
39+
head_tail_swallowed_modifiers = [
3540
"<user.cursorless_simple_modifier>", # bounds, just, leading, trailing
36-
"<user.cursorless_interior_modifier>", # inside
37-
"<user.cursorless_head_tail_modifier>", # head, tail
3841
"<user.cursorless_containing_scope>", # funk, state, class
3942
"<user.cursorless_subtoken_scope>", # first past second word
4043
"<user.cursorless_surrounding_pair>", # matching/pair [curly, round]
4144
]
4245

46+
modifiers = [
47+
"<user.cursorless_position>", # before, end of
48+
"<user.cursorless_interior_modifier>", # inside
49+
"<user.cursorless_head_tail_modifier>", # head, tail
50+
*head_tail_swallowed_modifiers,
51+
]
52+
4353

4454
@mod.capture(rule="|".join(modifiers))
4555
def cursorless_modifier(m) -> str:
4656
"""Cursorless modifier"""
4757
return m[0]
4858

4959

60+
@mod.capture(rule="|".join(head_tail_swallowed_modifiers))
61+
def cursorless_head_tail_swallowed_modifier(m) -> str:
62+
"""Cursorless modifier that is swallowed by the head/tail modifier, excluding interior, which requires special treatment"""
63+
return m[0]
64+
65+
5066
def on_ready():
5167
init_csv_and_watch_changes(
5268
"modifiers",

0 commit comments

Comments
 (0)