Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing import for code action #1272

Open
nyarly opened this issue Oct 19, 2024 · 1 comment
Open

Use existing import for code action #1272

nyarly opened this issue Oct 19, 2024 · 1 comment

Comments

@nyarly
Copy link

nyarly commented Oct 19, 2024

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
@razzeee
Copy link
Member

razzeee commented Oct 19, 2024

You should be running elm-format with this. It will automatically combine them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants