Language server falls out of sync with users workspace while editing
@Braqzen noticed some strange syntax highlighting behavior which was noted in https://github.com/FuelLabs/sway-vscode-plugin/issues/92
I was able to replicate this locally and have tracked down the cause of the problem. In the language server, we are calling forc::check on each didChange event. This fn takes the path of the manifest and then loads the project from disk to compile and return the parsed and typed AST's.
The problem is, if the user has not saved the file in between each edit, then the Spans returned in the ASTs do not reflect the current edits that the user has made. This is then causing the capabilities such as, semantic tokens, warnings, go_to etc to have mismatched locations.
I'm currently working on a solution that clones the workspace into a temp directory that LSP can use for processing. On every didChange event, we can write the file to disk in order to get an up-to-date directory in which to produce ASTs that reflect the local environment.