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

[Haskell - HLS] Some LSP Hints are not applied. "Outdated workspace edit for ..." #6543

Closed
0rphee opened this issue Apr 1, 2023 · 7 comments
Labels
C-bug Category: This is a bug upstream

Comments

@0rphee
Copy link
Contributor

0rphee commented Apr 1, 2023

Summary

Some haskell LSP hints for refactoring, like removing unnecessary parentheses, redundant lambdas, etc. don't work, instead an error is shown in the status bar: Outdated workspace edit for path/to/file.hs

Other LSP code actions work correctly though, as far as I know only the suggestions marked as "hints" are affected.

ss.mov

Reproduction Steps

I tried this:

  1. hx file.hs
  2. add func = \a -> a
  3. LSP hint will appear: "Redundant lambda (...)"
  4. space + a to apply code action Apply Redundant lambda

I expected this to happen:

Code action is executed.

Instead, this happened:

Nothing happens and error is thrown: Outdated workspace edit for path/to/file.hs

Helix log

~/.cache/helix/helix.log
2023-04-01T16:01:07.494 helix_term::commands::lsp [ERROR] outdated workspace edit for "/Users/roger/Documents/Dev/haskell-proj/schedule-maker/src/Lib.hs", expected 3548 but got 0
2023-04-01T16:01:07.494 helix_view::editor [ERROR] editor error: outdated workspace edit for "/Users/roger/Documents/Dev/haskell-proj/schedule-maker/src/Lib.hs"

Platform

macOS aarch64

Terminal Emulator

Alacritty 0.12.0 (1)

Helix Version

23.03-1-g406c5c38

@0rphee 0rphee added the C-bug Category: This is a bug label Apr 1, 2023
@pascalkuthe
Copy link
Member

I can reproduce this but this seems like an upstream issue.

The LS standard contains the notion of a document version. Whenever a document is edited a new unique version is created. Any change is associated with a unique id and if that version doesn't match the client version then the edit is invalid and ignored by the client (as happens here).

Looking at the logs it seems that the haskell language server sends the correct version for the most part but for some events the version is just set to Number(0). Perhaphs they meant to send null (in which case the version is ignored)? Either way there is nothing we can do about this on our side.

It seems that this currently works in vscode because vscode isn't as strict as it could/should be about enforcing these versions currently. This is a known issue with the vscode language client. See for example microsoft/vscode-languageserver-node#752 (comment).

@0rphee
Copy link
Contributor Author

0rphee commented Apr 1, 2023

Hmm, thats unfortunate. I'll go with the HLS folks then. Thanks!

(p.s. I updated the first comment with the logs, if there's any use to that, it seems to happen what you said)

@Deepaksinghmar
Copy link

Just take down RRP request and reboot the system.

@July541
Copy link

July541 commented Apr 18, 2023

I through the logic about executing code action, finding the helix increased the version while executing. May I confirm that it's the client's duty to increase the version, and the server just needs to supply the doc version it received?

@pascalkuthe
Copy link
Member

Yes only the client manages the document versions. Every time the client sends a document to the server (mostly with textDocument/didChange) it sends a version identifier. The server must either process events consequitively or use snapshots of the document so that it always knows what document version is the current one. An edit sent to the client belongs to a single document version and can only be used when that version matches the version of the client. Otherwise the edit could be incorrect and messup the document (or cause a crash)

@July541
Copy link

July541 commented Apr 18, 2023

@pascalkuthe Got it! Thanks for your detailed sharing!

@0rphee
Copy link
Contributor Author

0rphee commented Jul 27, 2023

Fixed with haskell/haskell-language-server#3643

@0rphee 0rphee closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug upstream
Projects
None yet
Development

No branches or pull requests

4 participants