Skip to content

Commit

Permalink
Pass individual changes to browser extension
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Jan 8, 2025
1 parent 1bffae5 commit 33ad7d1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cursorless-everywhere-talon/cursorless_everywhere_talon_browser.py
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

0 comments on commit 33ad7d1

Please sign in to comment.