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

fix document state getting out of sync in rare cases #2375

Merged
merged 3 commits into from
Dec 13, 2023
Merged

Conversation

rchl
Copy link
Member

@rchl rchl commented Dec 13, 2023

I've reproduced a case where document state gets desynchronized on the LSP side. The issue seems to be only reproducible when there are at least two servers starting on a file (or maybe it just makes it more likely to happen). The easiest way to reproduce is to start ST, (re)open a file on which at least two servers will get started and start typing immediately. After undoing the changes LSP will show some stale errors.

Screen.Recording.2023-12-13.at.01.15.10.mov

This happened on opening the file. We have applied all latest changes through didOpen when the change count was, let's say, 1, but there was also already pending text change notification with a change count of 1 which we have applied again a little later.

To fix, ignore text change notification that refer to current or old versions of the view since those are already applied/synced.

I was trying to think whether there is some deeper issue in the code that should be fixed instead but given how async tasks are scheduled, I don't think there is and it's just an expected case that we need to handle.

rchl and others added 3 commits December 13, 2023 01:09
@rwols rwols merged commit df4b5e4 into main Dec 13, 2023
4 checks passed
@rwols rwols deleted the fix/sync-on-open branch December 13, 2023 13:52
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