Skip to content

Completions can insert redundant imports #2270

Open
@pepeiborra

Description

@pepeiborra

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions