Closed
Description
HLS version:
I'm using
$ haskell-language-server --version
haskell-language-server version: 2.6.0.0 (GHC: 9.6.4)
But this behavior could be reproduced with earlier versions of GHC.
Steps to reproduce
Try to use Define
code action on name that is close enough to already existing identifier, e.g.
main :: IO ()
main = fooo ()
foo :: Int
foo = _
Here we already have foo
(two "o") in the scope and on unknown identifier fooo
(three "o") GHC will suggest fix "Perhaps use ‘foo’". This suggestion goes directly into code action, so it will define
fooo :: () -> IO () Suggested fix: Perhaps use ‘foo’ (line 7)
fooo = _
Expected behaviour
Strip the suggestion
fooo :: () -> IO ()
fooo = _
Related code
As I can see, related code is this function:
It propagates parsed type to code action builder here:
And newDefinitionAction
builds code action without any post-processing.
I'm not sure why typ:_ <- T.splitOn " Suggested fix:" typ0
doesn't work, additional debug is required.