Skip to content

Sending LSP messages very quickly causes all diagnostics to disappear #812

Closed
haskell/ghcide
#959
@tomsmeding

Description

@tomsmeding

This is an issue I encounter when using ghcide using ALE in neovim. (However, the issue can be reproduced without any of that; see below.)

Symptom
While working on code (in neovim using ALE), an edit action, as well as a :w save action, has a reasonable probability of removing all diagnostics from the current file. This is especially frequent on save and on pressing ESC to exit insert mode. It can usually be fixed by doing another edit action and undo'ing that, but it is quite annoying nevertheless.

Reproduction
Save this script to a file, say ghcide-fast-send-bug.py, and then run python3 ghcide-fast-send-bug.py fast | ghcide --lsp. Note that the last LSP message printed by ghcide is an empty diagnostic list, while there is certainly still an error in the file.
Removing the fast command-line argument adds a 2-second delay between the last two LSP messages printed by the script (please see the script!), which makes the bug disappear on my machine.

I believe the script should work on any machine, but perhaps things like the root path need to be changed to an existing path on your machine. I'm not familiar enough with the LSP protocol to say something sensible about that.

System
Arch Linux, ghcide manually built on commit 27b4250 (one above v0.6.0, and current HEAD). ghcide was built using cabal 3.2.0.0, ghc version 8.8.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions