-
Notifications
You must be signed in to change notification settings - Fork 204
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
Fixes and improvements around text synchronisation #411
Conversation
fixes some issues when certain sequence of notifications would create nil entries in source_files map
fix some consistency issues: dirty? flag not updated when file modified outside (no didSave) rebuild not triggered when opened dirty file modified outside
based on https://github.com/microsoft/vscode-languageserver-node fixes a few edge cases when dealing with invalid ranges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, and is an impressive list of fixes! ❤️
|> (&binary_part( | ||
&1, | ||
0, | ||
min(start_character * 2, byte_size(&1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why min
is needed here? And why min/max
is needed for the other similar call later in the file. I'm thinking that it would be better to extract a helper function since this function is already quite large and indexing into a utf8 string as if it was utf16 is a nice well-contained problem. I took a stab at doing it myself, but I wasn't clear on the min/max
constraints so I couldn't integrate those well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without that it crashes with ArgumentError when range is invalid (starts at negative, starts over length or takes more chars than are in binary). It shouldn't happen normally but it does when client looses synch with the server, e.g. in #277
The previous implementation did not have any bugs (that I saw), but I did find it more difficult to read and understand. I expect performance to be comparable. For more comprehensive testing I have added StreamData which adds property-based testing. We can probably use that in other portions of the code base as well.
Co-authored-by: Jason Axelson <axelson@users.noreply.github.com>
Refactor implementation of SourceFile.lines_with_endings
This PR fixes several spec compliance issues and consistency bugs.
all requests involving not tracked URIs will now return InvalidParam error code
didOpen
/didClose
etc. notifications are now rejectedadds test coverage
nil
entry could be createddidChangeWatchedFiles
handlerdirty?
flag not removedSourceFile
\r\n
and\r
not being preserved (spec requires preservation)SourceFile.full_range
(Comprehensive approach to utf-16 positions #244)Fixes #12