Skip to content

vscode: Instead of expecting certain remote edits, expect their result#390

Merged
zormit merged 3 commits intomainfrom
vscode-compare-results
Sep 25, 2025
Merged

vscode: Instead of expecting certain remote edits, expect their result#390
zormit merged 3 commits intomainfrom
vscode-compare-results

Conversation

@blinry
Copy link
Copy Markdown
Contributor

@blinry blinry commented Sep 24, 2025

When a remote edit replaces "x" with "XxX", VS Code will see a
TextDocumentChangeEvent that inserts two X's around the x. Because of
that, it's not possible to directly compare the edits.

Here's a proposed solution: Store the expected resulting content of the
document after the remote edit, then see if a local edit results in that
content.

When a remote edit replaces "x" with "XxX", VS Code will see a
TextDocumentChangeEvent that inserts two X's around the x. Because of
that, it's not possible to directly compare the edits.

Here's a proposed solution: Store the expected resulting content of the
document after the remote edit, then see if a local edit results in that
content.
@blinry
Copy link
Copy Markdown
Contributor Author

blinry commented Sep 24, 2025

I still managed to have some inconsistencies by running this script in Neovim:

:lua t = vim.uv.new_timer(); t:start(0, 30, vim.schedule_wrap(function() vim.api.nvim_buf_set_text(0, 0, 0, 
0, 2, {"xxx"}) end))

And then inserting/deleting x'es in the second line in VS Code. This will sometimes result in errors like this:

"Could not convert UTF-16 code unit offset 123 to char offset in string 'xxx...'"

@blinry blinry marked this pull request as ready for review September 25, 2025 15:54
@blinry blinry requested a review from zormit September 25, 2025 15:54
@zormit zormit merged commit 3d06e4b into main Sep 25, 2025
1 check passed
@zormit zormit deleted the vscode-compare-results branch September 25, 2025 15:54
@blinry
Copy link
Copy Markdown
Contributor Author

blinry commented Sep 25, 2025

Even though this PR doesn't solve all VS Code consistency issues, we decided that it's an improvement, and we can iterate more on it in the future.

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.

2 participants