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

Fixes and improvements around text synchronisation #411

Merged
merged 29 commits into from
Nov 24, 2020

Conversation

lukaszsamson
Copy link
Collaborator

This PR fixes several spec compliance issues and consistency bugs.

  • makes it impossible to get crashes like Bug: function nil.text/0 is undefined exception #12
    all requests involving not tracked URIs will now return InvalidParam error code
  • not matched didOpen/didClose etc. notifications are now rejected
    adds test coverage
  • fixes an issue introduced in 1533d0a when nil entry could be created
  • fixes various issues in didChangeWatchedFiles handler
    • fixes differences in registered vs handled watched file extensions
    • fixes a case when build was not triggered
    • fixes a case when dirty? flag not removed
    • adds test coverage
  • adds test coverage to change application in SourceFile
    • fixes handling of invalid ranges
    • fixes \r\n and \r not being preserved (spec requires preservation)
  • fixes invalid range returned in SourceFile.full_range (Comprehensive approach to utf-16 positions #244)
  • checks client response on various client requests

Fixes #12

Copy link
Member

@axelson axelson left a 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))
Copy link
Member

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.

Copy link
Collaborator Author

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

axelson and others added 2 commits November 23, 2020 16:54
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.
@axelson axelson merged commit 0851d87 into elixir-lsp:master Nov 24, 2020
axelson added a commit that referenced this pull request Nov 26, 2020
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.

Bug: function nil.text/0 is undefined exception
2 participants