dense-analysis / dense-analysis/ale

ALEImport always applies first suggestion ignoring everything else.

Open
#4,085 1 comment 0 reactions 0 assignees View on GitHub
enhancement LSP
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

When running ALEImport the LSP can return multiple options to import but ALE simply takes and applies the first one. Would be better if ALE instead shows an auto-complete menu and allows the user to select which item to import.

Tested this with eclipselsp on a project that uses [Joda Time](https://www.joda.org/joda-time/) that has its own implementations of LocalDate and LocalDateTime classes. When calling ALEImport on either of those classes the system.time.LocalDate gets imported without giving the option to the user to select org.joda.time.LocalDate instead.

Checking the code this seems to be fixable by modifying these parts:

- https://github.com/dense-analysis/ale/blob/master/autoload/ale/completion.vim#L377 logic here seems to only open the completion popup if the source is ale-manual or ale-automatic. The ale-import source used when calling ALEImport is not considered.
- https://github.com/dense-analysis/ale/blob/master/autoload/ale/completion.vim#L9 Seems the popup menu only displays in insert mode. ALEImport is invoked in normal mode so the menu won't appear.

On my limited testing I was unable to get the popup shown by modifying these parts of the code. I did verify that eclipselsp is indeed returning multiple completion items with additional text edits for the possible imports but ALE refuses to show the popup.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.