haskell / haskell/haskell-language-server

Completions can insert redundant imports

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

Description

In 1.4.0 we introduced completions for all local identifiers in the project. These completions automatically insert missing imports. It turns out that we don't verify whether the imports are actually missing, leading to some problems:

1. Redundant imports, if the import already exists
2. Conflicting import, if it's a redundant import that conflicts with something that already exists
3. Circular imports, if the completed identifier is defined in the module being edited

All the above are painful, but 2 and 3 are specially annoying.

The solution for this would be:
- for 1, to perform an isNeeded check in the command that inserts the new import.
- for 3, to verify that the inserted module and the current module are different
- 2 is a bug in the ordering of the completion suggestions. For example the user could legitimally want to use `ByteString` from `Data.ByteString.Lazy` even if `Data.ByteString` is already imported. The bug is in suggesting the non-imported completion before the imported one.

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.