-
-
Notifications
You must be signed in to change notification settings - Fork 391
Minor "import action" formatting bug #2414
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
Comments
Minor but interesting bug, have you any intuition about what triggers it, the place of the |
I think so, now that I tried it out again the explicit export doesn't seem to matter. I also feel like this is a regression, but not 100% sure. |
I have a very strong feeling that this happens when )
where and does not happen when they are on the name line: ) where ormolu formats export lists the first way and the initial import is broken. If you already have imports, the positioning of the |
A quick experiment shows that for a file like this, nothing represents the module Asdf
(f)
where
f :: Int64 -> Int64
f = id When there is no existing import declaration, the current implementation uses So if there is no way to extract the location of |
By the way, linking a related issue #2425 to make the context clearer. |
The recommended solution is to use We already have an exactprint function to extend imports that can serve as example: haskell-language-server/ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs Lines 329 to 335 in 4386396
|
* #2414 fix new import position * fix auto import for ghc version < 9.2 * re-fix it for ghc-9.2 * handle comments * add more comments * reword comments of findPositionNoImports Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* haskell#2414 fix new import position * fix auto import for ghc version < 9.2 * re-fix it for ghc-9.2 * handle comments * add more comments * reword comments of findPositionNoImports Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
HLS
--version
Your environment
Output of
haskell-language-server --probe-tools
orhaskell-language-server-wrapper --probe-tools
:tauren :: /tmp » haskell-language-server-wrapper --probe-tools haskell-language-server version: 1.5.0.0 (GHC: 8.10.7) (PATH: /home/googleson78/.ghcup/bin/haskell-language-server-wrapper-1.5.0) (GIT hash: 311107eabbf0537e0c192b2c377d282505b4eff1) Tool versions found on the $PATH cabal: 3.6.2.0 stack: 2.7.3 ghc: 8.10.7
Which OS do you use:
Debian
Which lsp-client do you use:
nvim, LanguageClient-neovim
Describe your project:
Reproduces with a standalone file and in a stack project
Steps to reproduce
Try to use the import action for
Int64
with these file contents.Expected behaviour
(or some other valid result)
Actual behaviour
Include debug information
Debug output:
The text was updated successfully, but these errors were encountered: