Skip to content

Commit 4959e3e

Browse files
AndreasArvidssonAndreas Arvidssonpre-commit-ci[bot]pokey
authored andcommitted
Updated head tail modifier to not swallow all following modifiers (cursorless-dev#809)
* Updated head tail modifier to not swallow all following modifiers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Andreas Arvidsson <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <[email protected]>
1 parent 51ef00c commit 4959e3e

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

src/modifiers/head_tail.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,32 @@
1313
)
1414

1515

16-
@mod.capture(rule="{user.cursorless_head_tail_modifier} <user.cursorless_modifier>*")
16+
@mod.capture(
17+
rule=(
18+
"{user.cursorless_head_tail_modifier} "
19+
"[<user.cursorless_interior_modifier>] "
20+
"[<user.cursorless_modifier>]"
21+
)
22+
)
1723
def cursorless_head_tail_modifier(m) -> dict[str, str]:
1824
"""Cursorless head and tail modifier"""
19-
result = {
20-
"type": m.cursorless_head_tail_modifier,
21-
}
25+
modifiers = []
26+
2227
try:
23-
result["modifiers"] = m.cursorless_modifier_list
28+
modifiers.append(m.cursorless_interior_modifier)
2429
except AttributeError:
2530
pass
31+
32+
try:
33+
modifiers.append(m.cursorless_modifier)
34+
except AttributeError:
35+
pass
36+
37+
result = {
38+
"type": m.cursorless_head_tail_modifier,
39+
}
40+
41+
if modifiers:
42+
result["modifiers"] = modifiers
43+
2644
return result

src/modifiers/interior.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from talon import Module
2+
3+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
4+
# See https://www.cursorless.org/docs/user/customization/
5+
interior_modifiers = {
6+
"inside": "interiorOnly",
7+
}
8+
9+
mod = Module()
10+
11+
mod.list(
12+
"cursorless_interior_modifier",
13+
desc="Cursorless interior modifier",
14+
)
15+
16+
17+
@mod.capture(rule="{user.cursorless_interior_modifier}")
18+
def cursorless_interior_modifier(m) -> dict[str, str]:
19+
"""Cursorless interior modifier"""
20+
return {
21+
"type": m.cursorless_interior_modifier,
22+
}

src/modifiers/modifiers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
from ..csv_overrides import init_csv_and_watch_changes
44
from .head_tail import head_tail_modifiers
5+
from .interior import interior_modifiers
56
from .range_type import range_types
67

78
mod = Module()
89

910
# NOTE: Please do not change these dicts. Use the CSVs for customization.
1011
# See https://www.cursorless.org/docs/user/customization/
1112
simple_modifiers = {
12-
"inside": "interiorOnly",
1313
"bounds": "excludeInterior",
1414
"just": "toRawSelection",
1515
"leading": "leading",
@@ -32,7 +32,8 @@ def cursorless_simple_modifier(m) -> dict[str, str]:
3232

3333
modifiers = [
3434
"<user.cursorless_position>", # before, end of
35-
"<user.cursorless_simple_modifier>", # inside, bounds, just, leading, trailing
35+
"<user.cursorless_simple_modifier>", # bounds, just, leading, trailing
36+
"<user.cursorless_interior_modifier>", # inside
3637
"<user.cursorless_head_tail_modifier>", # head, tail
3738
"<user.cursorless_containing_scope>", # funk, state, class
3839
"<user.cursorless_subtoken_scope>", # first past second word
@@ -51,6 +52,7 @@ def on_ready():
5152
"modifiers",
5253
{
5354
"simple_modifier": simple_modifiers,
55+
"interior_modifier": interior_modifiers,
5456
"head_tail_modifier": head_tail_modifiers,
5557
"range_type": range_types,
5658
},

0 commit comments

Comments
 (0)