Skip to content

Use existing import for code action #1272

@nyarly

Description

@nyarly

When ELS suggests e.g. Import 'button' from module 'Html', if the Html module is already imported, the exposing (button) should be added to the existing import, not added as a new import Html

Expected Behavior

Given

import Html exposing (div)

foo = 
  button [] []

triggering a code action on button and selecting Import 'button' from module "Html" should result in

import Html exposing (div, button)

foo =
  button [] []

Current Behavior

Instead we get:

import Html exposing (div)
import Html exposing (button)

Context

The resulting imports look sloppy and are hard to follow. I wind up spending as much time tiding them up as I save using the auto-import action.

Your Environment

  • Version used: 2.8.0
  • Editor used: Neovim 0.10.1
  • Environment name and version (e.g. node.js 5.4): node 22.5.1
  • Operating System and version: NixOS 24.05

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions