Skip to content

Commit

Permalink
Take snapshots of hat map (#101)
Browse files Browse the repository at this point in the history
* Touch file impl

* Improved touch

* Fix field name

* Initial attempt at more robustness

* Working version

* Revert change to mark.py
  • Loading branch information
pokey committed Dec 13, 2021
1 parent 0cb8367 commit 774196f
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def cursorless_single_target_command_get(
arg3: Any = NotSet,
):
"""Execute single-target cursorless command and return result"""
args = list(filter(lambda x: x is not NotSet, [arg1, arg2, arg3]))
return actions.user.vscode_get(
"cursorless.command",
get_spoken_form(),
action,
[target],
*args,
construct_cursorless_command_argument(
action=action,
targets=[target],
args=[x for x in [arg1, arg2, arg3] if x is not NotSet],
),
)

def cursorless_multiple_target_command(
Expand All @@ -78,15 +78,33 @@ def cursorless_multiple_target_command(
arg3: any = NotSet,
):
"""Execute multi-target cursorless command"""
args = list(filter(lambda x: x is not NotSet, [arg1, arg2, arg3]))
actions.user.vscode_with_plugin_and_wait(
"cursorless.command",
get_spoken_form(),
action,
targets,
*args,
construct_cursorless_command_argument(
action=action,
targets=targets,
args=[x for x in [arg1, arg2, arg3] if x is not NotSet],
),
)


def construct_cursorless_command_argument(
action: str, targets: list[dict], args: list[any]
):
try:
use_pre_phrase_snapshot = actions.user.did_emit_pre_phrase_signal()
except KeyError:
use_pre_phrase_snapshot = False

return {
"version": 1,
"spokenForm": get_spoken_form(),
"action": action,
"targets": targets,
"extraArgs": args,
"usePrePhraseSnapshot": use_pre_phrase_snapshot,
}


def get_spoken_form():
return " ".join(last_phrase["phrase"])

0 comments on commit 774196f

Please sign in to comment.