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

Some LSP Code actions (Hints) are not applied. #3547

Closed
0rphee opened this issue Apr 1, 2023 · 6 comments
Closed

Some LSP Code actions (Hints) are not applied. #3547

0rphee opened this issue Apr 1, 2023 · 6 comments
Labels
component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@0rphee
Copy link
Collaborator

0rphee commented Apr 1, 2023

Your environment

Which OS do you use?
MacOS aarch64

Which version of GHC do you use and how did you install it?
9.2.7 from ghcup

How is your project built (alternative: link to the project)?
stack

Which LSP client (editor/plugin) do you use?
Helix

Which version of HLS do you use and how did you install it?
1.10.0.0 from ghcup

Have you configured HLS in any way (especially: a hie.yaml file)?
No

Steps to reproduce

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

Expected behaviour

Code action is executed.

Actual behaviour

Error is shown in the editor: Outdated workspace edit for path/to/file.hs 
(This seems to only apply to "code hints".)

Debug information

After asking in the helix repo (helix-editor/helix#6543), I received this response:

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).

The 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"
@0rphee 0rphee added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Apr 1, 2023
@July541
Copy link
Collaborator

July541 commented Apr 16, 2023

Can you test if the action for class instance works? I think it will report an error too.

image

@0rphee
Copy link
Collaborator Author

0rphee commented Apr 18, 2023

@July541 Well, at first it worked, then it didn't:

ss.mov

The helix log:

2023-04-17T17:59:29.015 helix_lsp::transport [ERROR] err <- "2023-04-17T23:59:29.015215Z | Info | class: Detected implemented methods for class \"F\": []\n"
2023-04-17T17:59:30.004 helix_term::commands::lsp [ERROR] outdated workspace edit for "/Users/roger/Documents/Dev/main.hs", expected 2 but got 0
2023-04-17T17:59:30.004 helix_view::editor [ERROR] editor error: outdated workspace edit for "/Users/roger/Documents/Dev/main.hs"
2023-04-17T17:59:31.273 helix_lsp::transport [ERROR] err <- "2023-04-17T23:59:31.272845Z | Info | class: Detected implemented methods for class \"F\": []\n"
2023-04-17T17:59:31.983 helix_term::commands::lsp [ERROR] outdated workspace edit for "/Users/roger/Documents/Dev/main.hs", expected 2 but got 0
2023-04-17T17:59:31.984 helix_view::editor [ERROR] editor error: outdated workspace edit for "/Users/roger/Documents/Dev/main.hs"
2023-04-17T17:59:33.870 helix_lsp::transport [ERROR] err <- "2023-04-17T23:59:33.870531Z | Info | class: Detected implemented methods for class \"F\": []\n"
2023-04-17T17:59:34.476 helix_term::commands::lsp [ERROR] outdated workspace edit for "/Users/roger/Documents/Dev/main.hs", expected 2 but got 0
2023-04-17T17:59:34.476 helix_view::editor [ERROR] editor error: outdated workspace edit for "/Users/roger/Documents/Dev/main.hs"

@0rphee
Copy link
Collaborator Author

0rphee commented Apr 18, 2023

Here's also the example video of the problem I posted in the original helix issue:

ss.mov

@July541
Copy link
Collaborator

July541 commented Apr 18, 2023

Well, I see it. Indeed we send version 0 to the client and it caused code action to fail.

Just need a confirm before fixing it up.

@maralorn
Copy link
Contributor

This should be fixed by the just merged #3643.

@0rphee
Copy link
Collaborator Author

0rphee commented Jul 27, 2023

Yeah it works just right now! thanks!

@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
component: hls-hlint-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants