haskell / haskell/haskell-language-server

Code action not showing on multi-line imports with unused record field

Open
#4,310 3 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

### Steps to reproduce

Given `ModuleB`:

```haskell
module ModuleB where
newtype B = B {b1 :: String}
x = 1
```

and `ModuleA` which has an unused record field import within a multi-line import statement:

```haskell
module ModuleA where
import ModuleB
( B (b1),
x,
)
x' = x
```

### Expected behaviour

I expect the code action for removing the unused record field: `Remove B, B(b1) from import` to be shown on selecting the single line with the unused import.

### Actual behaviour

Instead, the code action does not show:

![image](https://github.com/haskell/haskell-language-server/assets/3968185/9b3cb920-9c6c-4ba0-b5fe-682c788768a6)

However, it shows when collecting the complete range of the import statement.

![image](https://github.com/haskell/haskell-language-server/assets/3968185/12d16dca-4fb7-4e61-810b-62c723fe2580)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the ModuleA and ModuleB snippets, selecting the single line containing the unused record field and then the complete import range. The change is done when the “Remove B, B(b1) from import” code action appears for the single-line selection as well.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.