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

Pass individual changes to browser extension #2709

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from talon import Context, Module, actions

from .cursorless_everywhere_types import EditorEdit, EditorState, SelectionOffsets
from .cursorless_everywhere_types import (
EditorChange,
EditorEdit,
EditorState,
SelectionOffsets,
)

mod = Module()

Expand Down Expand Up @@ -43,8 +48,9 @@ def cursorless_everywhere_edit_text(
edit: EditorEdit, # pyright: ignore [reportGeneralTypeIssues]
):
command = {
"id": "setText",
"id": "editText",
"text": edit["text"],
"changes": get_serializable_editor_changes(edit["changes"]),
}
res = rpc_get(command)
if use_fallback(res):
Expand All @@ -71,3 +77,17 @@ def get_serializable_selections(selections: list[SelectionOffsets]):
}
)
return result


def get_serializable_editor_changes(changes: list[EditorChange]):
result: list[EditorChange] = []
for i in range(changes.length): # pyright: ignore [reportAttributeAccessIssue]
change = changes[i]
result.append(
{
"text": change["text"],
"rangeOffset": change["rangeOffset"],
"rangeLength": change["rangeLength"],
}
)
return result
Loading