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

Auto import doesn't work #2142

Closed
sohnryang opened this issue Apr 17, 2022 · 6 comments
Closed

Auto import doesn't work #2142

sohnryang opened this issue Apr 17, 2022 · 6 comments
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@sohnryang
Copy link
Contributor

sohnryang commented Apr 17, 2022

Summary

I tried out the auto-import feature that got merged recently, but it is not working.

Reproduction Steps

I tried this:

  1. Create a new Rust project using cargo new test_project, and cd to the project root.
  2. Run the editor using hx src/main.rs.
  3. Make a new line after the line containing println!, and type Dur.
  4. LSP suggests Duration. Select it by pressing control-n.

I expected this to happen:
By selecting the suggestion, use std::time::Duration should be added to the source code.

Instead, this happened:
The editor completes to Duration, but does not add use statement to the code.

Helix log

The log is too long, so I'll attach it separately.
helix.log

Platform

Linux (kernel version: 5.17.2-arch3-1)
rust-analyzer 2022-04-11

Terminal Emulator

wezterm 20220408-101518-b908e2dd

Helix Version

22.03-95-gc45fb08a

@sohnryang sohnryang added the C-bug Category: This is a bug label Apr 17, 2022
@archseer
Copy link
Member

@andreytkachenko I also can't get this working, the completion appears but the import isn't getting added. I assume additionalTextEdits isn't resolved correctly

@kirawi kirawi added the A-language-server Area: Language server client label Apr 19, 2022
@andreytkachenko
Copy link
Contributor

andreytkachenko commented Apr 19, 2022

@archseer The only case I can reproduce the bug - if there are some changes happened between complete and resolve requests and server responds with content changed error (I guess we need handle that error somehow). But I didn't noticed any resolve requests in attached logs. It looks like additionalTextEdits contains something, but logs don't shows that additionalTextEdits in after complete contains something. Sorry I need more data to reproduce that. I am using RA version 2022-03-28, helix 22.05-dev (855e438), both debug and release, wezterm, alacritty, gnome-terminal. But unable to reproduce it. I did pure clone and pure cargo new for demo project, but it works.

@theli-ua
Copy link
Contributor

theli-ua commented Jun 10, 2022

I can reproduce this if I start typing Dur and make selection before ra completes indexing/etc. With "content modified" error from server

@sohnryang
Copy link
Contributor Author

I realized that I had to press enter in order to get auto-import... 😅
Works fine for me now. Should I close this ticket?

@andreytkachenko
Copy link
Contributor

I can confirm that problem is not solved. I will fix it. Leave it open please for reference.

@pascalkuthe
Copy link
Member

I can not reproduce this anymore. It's hard to retroactively pinpoint but I guess this was likely fixed by #6173 or #6594 (likely the latter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

7 participants
@theli-ua @archseer @andreytkachenko @sohnryang @pascalkuthe @kirawi and others