Haskell-language-server: Two code actions for import module name; one of them is broken

Created on 26 Nov 2020  路  3Comments  路  Source: haskell/haskell-language-server

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.6.0.0 (GHC: 8.10.2) (PATH: /home/jjc93/.local/bin/haskell-language-server-wrapper) (GIT hash: d79feb5bf5d9a33003125e2988d7c0dc7174b8d5)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.10.2

Which lsp-client do you use:
Emacs with LSP-mode
Describe your project (alternative: link to the project):
It is a project created by cabal init.
Contents of hie.yaml: Nothing (implicit yaml)

Steps to reproduce

  1. create a project using cabal init.
  2. go to Main.hs file, and type import Data.E.
  3. try all code actions for Data.Eq.

Expected behaviour

There is only one code action for Data.Eq, and it replaces import Data.E with import Data.Eq.

Actual behaviour

LSP-mode shows there are two actions. HLS log also conforms to that. One of the actions substitutes Data.Eq for import Data.E.

ghcide blocked upstream bug

All 3 comments

I could reproduce this in ghcide, so it was not caused by the same reason as #380. Two diagnostic messages showd up for a single import line, but they were essentially the same, though It seemed that they came from two different ways:

image

And I also found an interesting thing:

image
image

Because two diagnostic messages were in different ranges, code actions generated from those two messages followed them as well ;)

In addition, "Use -v (or :set -v in ghci) to see a list of the files searched for" could be the last line of the diagnostic message, which would generate an unexpected code action:
image

Oh, it's good to know that the bug is actually not editor specific and come from ghcide. Thank you for investing the problem.

Was this page helpful?
0 / 5 - 0 ratings