haskell / haskell/haskell-language-server

Import code action imports inside of CPP

Open
#1,490 1 comment 1 reaction 0 assignees View on GitHub
component: ghcide type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
2d 19h
Merged PRs (30d)
11

Description

### Your environment
Output of `haskell-language-server --probe-tools` or `haskell-language-server-wrapper --probe-tools`:

```sh
haskell-language-server version: 1.0.0.0 (GHC: 8.8.4) (PATH: /home/sandy/.local/bin/haskell-language-server) (GIT hash: 25252164db6b2a01ccb0a7436009478ce2939f0a)
Tool versions found on the $PATH
cabal: 3.2.0.0
stack: 2.3.3
ghc: 8.10.4
```
Which lsp-client do you use: vim/coc

### Steps to reproduce
```haskell
{-# LANGUAGE CPP #-}

import Prelude
#ifdef __GLASGOW_HASKELL__
import Data.Maybe
#endif

foo :: All
foo = All True
```

Use the "Import`All` from `Data.Monoid`" code action.

### Expected behaviour
```haskell
import Prelude
import Data.Monoid
#ifdef __GLASGOW_HASKELL__
import Data.Maybe
#endif
```

### Actual behaviour
```haskell
import Prelude
#ifdef __GLASGOW_HASKELL__
import Data.Maybe
import Data.Monoid
#endif
```

### Why this is frustrating

Rather than using ifdef, consider if the CPP is `#if __GLASGOW_HASKELL__ == 808`, then your imports only get added for your current compiler version.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.