Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some edits not being sent to LangServ (#3186)
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()`](https://github.com/enso-org/enso/blob/c14a2d81698217349394597fea778fd86bba47df/app/gui/src/controller/project.rs#L137-L141), was not reaching the Language Server. The cause of it was a race condition with [`self.model.subscribe()` in `Module::runner()`](https://github.com/enso-org/enso/blob/c14a2d81698217349394597fea778fd86bba47df/app/gui/src/model/module/synchronized.rs#L268). 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()`](https://github.com/enso-org/enso/blob/7467efda592ab5d7ce29122af20020293f9ceacf/app/gui/src/model/module/synchronized.rs#L362), 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.
- Loading branch information