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 some edits not being sent to LangServ #3186

Merged
merged 30 commits into from
Dec 13, 2021

Conversation

akavel
Copy link
Contributor

@akavel akavel commented Dec 8, 2021

Pull Request Description

Some edits were not being sent by IDE to Language Server, resulting in 3003 "Invalid version" errors being returned by LangServ, and forcing full invalidation (resynchronization) of text contents in LangServ.

This change fixes such errors observed when opening a new project, creating a new project, or adding a new node to a project.

Fixes #3094

Important Notes

The root cause showed up to be actually two separate issues, both of them reproduced by an "opening a new project" scenario:

  1. The automatic addition of import Standard.Visualization line, done internally when opening a new project in controller::Project::initialize(), was not reaching the Language Server. The cause of it was a race condition with self.model.subscribe() in Module::runner(). In particular, the addition of the import was executed before the subscription, which resulted in an edition notification being lost and not sent to LangServer. The fix employed for this is to make the subscribe() call synchronous during the initialization of a project, instead of scheduling it for a non-deterministic later time.
  2. There was a bug in synchronized::Module::edit_for_snipped(), making it erroneously "optimize out" any code insertions detected by TextEdit::from_prefix_postfix_differences(). The fix employed for this was to improve the "optimizing out" condition, together with adding an accompanying test case verifying correct behavior (protecting against a future regression).

Additionally, as a drive-by improvement, some statements in ParsedSourceFile<>::serialize() were reordered, to make them better match how the actual contents of an .enso file are structured, and thus make it easier to read/analyze the code.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the Scala, Java, and Rust style guides.
  • All documentation and configuration conforms to the markdown and YAML style guides.
  • All code has been tested where possible.

@akavel akavel changed the title Fix applyEdit version mismatch Fix some edits not being sent to LangServ Dec 13, 2021
@akavel akavel marked this pull request as ready for review December 13, 2021 14:24
Copy link
Contributor

@farmaazon farmaazon left a comment

Choose a reason for hiding this comment

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

Only minor issues, please fix them before merging (they don't require re-review I think).

Comment on lines 9 to 11
- [Fixed "Invalid version" error during sending text change to Language
Server.][3186] The error happened during project opening and after new node
creation.
Copy link
Contributor

Choose a reason for hiding this comment

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

On the first place, I would say that an error in the console is fixed, because the user will notice rather log in the console than the error in Language Server communication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

❤️ thanks! done

app/gui/src/model/module/synchronized.rs Outdated Show resolved Hide resolved
@akavel akavel merged commit 050e52b into develop Dec 13, 2021
@akavel akavel deleted the wip/akavel/langserv-digest-mismatch-180558676 branch December 13, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants