Skip to content

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

Closed
@0rphee

Description

@0rphee

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-hlint-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions