Skip to content

Conversation

@AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented Jan 8, 2025

Today we only pass the text to the browser extension. This change also passes the changes/diffs themselves so we can update editor content without messing up the scrolling position.

Checklist

  • [/] I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson requested a review from a team as a code owner January 8, 2025 17:20
Comment on lines +84 to +93
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use a list comprehension here because changes it is not a true Python list, it's a QuickJS array which doesn't support that. We also don't have the ability to convert these JavaScript objects to Python with a one shot utility because certain reflection data is missing per Andreas.

But what we could do is make simple wrapping utilities that will convert one level of the tree:

  • JavaScript array to Python list (just does a iteration like this without looking at the objects in the array)
  • JavaScript dictionary to Python dictionary (you would have to pass exactly the keys you expect)

With this approach, we can contain the weirdness of the JavaScript objects to where we get them, requiring a couple of utility calls, and use proper Python code thereafter.

Merged via the queue into main with commit 785a750 Jan 10, 2025
15 checks passed
@AndreasArvidsson AndreasArvidsson deleted the cursorlessEverywhereBrowserChanges branch January 10, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants