Skip to content

Commit b403a73

Browse files
Use create functions for implicit and base target instead of copy() (#1593)
Fixes #719 ## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] 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) - [ ] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 9f87f79 commit b403a73

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

cursorless-talon/src/actions/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from talon import Module, actions, app
22

33
from ..csv_overrides import init_csv_and_watch_changes
4-
from ..primitive_target import IMPLICIT_TARGET
4+
from ..primitive_target import create_implicit_target
55
from .actions_callback import callback_action_defaults, callback_action_map
66
from .actions_simple import (
77
no_wait_actions,
@@ -49,7 +49,7 @@ def cursorless_command(action_id: str, target: dict):
4949
actions.sleep(no_wait_actions_post_sleep[action_id])
5050
elif action_id in ["replaceWithTarget", "moveToTarget"]:
5151
actions.user.cursorless_multiple_target_command(
52-
action_id, [target, IMPLICIT_TARGET.copy()]
52+
action_id, [target, create_implicit_target()]
5353
)
5454
else:
5555
return actions.user.cursorless_single_target_command(action_id, target)

cursorless-talon/src/actions/call.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from talon import Module, actions
22

3-
from ..primitive_target import IMPLICIT_TARGET
3+
from ..primitive_target import create_implicit_target
44

55
mod = Module()
66

77

88
def run_call_action(target: dict):
9-
targets = [target, IMPLICIT_TARGET.copy()]
9+
targets = [target, create_implicit_target()]
1010
actions.user.cursorless_multiple_target_command("callAsFunction", targets)

cursorless-talon/src/actions/move_bring.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from talon import Module
22

3-
from ..primitive_target import IMPLICIT_TARGET
3+
from ..primitive_target import create_implicit_target
44

55
mod = Module()
66

@@ -15,6 +15,6 @@ def cursorless_move_bring_targets(m) -> list[dict]:
1515
try:
1616
target_list += [m.cursorless_positional_target]
1717
except AttributeError:
18-
target_list += [IMPLICIT_TARGET.copy()]
18+
target_list += [create_implicit_target()]
1919

2020
return target_list

cursorless-talon/src/actions/swap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from talon import Module
22

3-
from ..primitive_target import BASE_TARGET
3+
from ..primitive_target import create_base_target
44

55
mod = Module()
66

@@ -20,6 +20,6 @@ def cursorless_swap_targets(m) -> list[dict]:
2020
target_list = m.cursorless_target_list
2121

2222
if len(target_list) == 1:
23-
target_list = [BASE_TARGET] + target_list
23+
target_list = [create_base_target()] + target_list
2424

2525
return target_list

cursorless-talon/src/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
run_rpc_command_get,
88
run_rpc_command_no_wait,
99
)
10-
from .primitive_target import IMPLICIT_TARGET
10+
from .primitive_target import create_implicit_target
1111

1212
mod = Module()
1313

@@ -90,7 +90,7 @@ def cursorless_implicit_target_command(
9090
):
9191
"""Execute cursorless command with implicit target"""
9292
actions.user.cursorless_single_target_command(
93-
action, IMPLICIT_TARGET, arg1, arg2, arg3
93+
action, create_implicit_target(), arg1, arg2, arg3
9494
)
9595

9696
def cursorless_multiple_target_command(

cursorless-talon/src/compound_targets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from talon import Module
44

55
from .connective import default_range_connective
6-
from .primitive_target import IMPLICIT_TARGET
6+
from .primitive_target import create_implicit_target
77

88
mod = Module()
99

@@ -46,7 +46,7 @@ def cursorless_range(m) -> dict[str, Any]:
4646
return primitive_targets[0]
4747

4848
if len(primitive_targets) == 1:
49-
anchor = IMPLICIT_TARGET.copy()
49+
anchor = create_implicit_target()
5050
else:
5151
anchor = primitive_targets[0]
5252

cursorless-talon/src/primitive_target.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55

66
mod = Module()
77

8-
BASE_TARGET: dict[str, Any] = {"type": "primitive"}
9-
IMPLICIT_TARGET = {"type": "implicit"}
8+
9+
def create_base_target() -> dict[str, Any]:
10+
return {"type": "primitive"}
11+
12+
13+
def create_implicit_target() -> dict[str, Any]:
14+
return {"type": "implicit"}
1015

1116

1217
@mod.capture(
@@ -17,7 +22,7 @@
1722
)
1823
def cursorless_primitive_target(m) -> dict[str, Any]:
1924
"""Supported extents for cursorless navigation"""
20-
result = BASE_TARGET.copy()
25+
result = create_base_target()
2126

2227
modifiers = [
2328
*getattr(m, "cursorless_position_list", []),

0 commit comments

Comments
 (0)