Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take snapshots of hat map #101

Merged
merged 7 commits into from
Dec 6, 2021
Merged
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
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,
pokey marked this conversation as resolved.
Show resolved Hide resolved
"usePrePhraseSnapshot": use_pre_phrase_snapshot,
}


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