Visitar URL original
“Add import” code action inserts the import inside a CPP #if/#else block · Issue #5136 · haskell/haskell-language-server · GitHub
Skip to content

“Add import” code action inserts the import inside a CPP #if/#else block #5136

Open

Description

@fabsch225

When accepting a suggested import (“Add import” code action) in a module that uses {-# LANGUAGE CPP #-}, the new import is inserted directly below the last existing import. If that import is inside a CPP conditional, the new import ends up in only one branch, so the module no longer compiles when the other branch is active.

{-# LANGUAGE CPP   #-}
-- ....
#if MIN_VERSION_ghc(9,7,0)
import           Data.Foldable                                (toList)
import           GHC.Unit.Module.Warnings
#else
import           Development.IDE.Core.FileStore               (shareFilePath)
-- Import is placed here!
#endif­

Expected: the import is inserted outside the conditional block (e.g. before #if or after #endif).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-refactor-pluginIssues related to the hls-refactor-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