fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.12k stars 39 forks source link

Extraneous backslashes in code-action auto completes #1228

Closed theKidOfArcrania closed 5 months ago

theKidOfArcrania commented 5 months ago

What's the output of :CocInfo

versions

vim version: VIM - Vi IMproved 9.0 9001499 node version: v16.14.1 coc.nvim version: 0.0.82-32329648 2024-02-26 18:54:56 +0800 coc.nvim directory: /home/***/.vim/plugged/coc.nvim term: dumb platform: linux

Log of coc.nvim

2024-02-26T11:32:22.342 INFO (pid:15534) [plugin] - coc.nvim initialized with node: v16.14.1 after 142 2024-02-26T11:32:22.343 INFO (pid:15534) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting 2024-02-26T11:32:22.349 INFO (pid:15534) [language-client-index] - Language server "rust-analyzer" started with 15551 2024-02-26T11:32:22.359 INFO (pid:15534) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running 2024-02-26T11:32:22.377 INFO (pid:15534) [services] - service rust-analyzer started 2024-02-26T11:32:28.315 INFO (pid:15534) [attach] - receive notification: codeAction [ 'line' ] 2024-02-26T11:32:33.774 INFO (pid:15534) [attach] - receive notification: showInfo [] 2024-02-26T11:32:37.165 INFO (pid:15534) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion rust-analyzer 0.3.1860-standalone

What's your coc-rust-analyzer version? You can get it from :CocList extensions coc-rust-analyzer 0.75.1

Given this simple rust snippet code:

struct Hi {
    field: String,
}

impl std::fmt::Debug for Hi {
}

If I were to activate code action "Implement missing members" for this impl Debug, I will get a number of backslashes specifically preceding the closing brace:

impl std::fmt::Debug for Hi {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct(name: "Hi").field(name: "field", value: &self.field).finish()
    \}
}
fannheyward commented 5 months ago

rust-analyzer https://github.com/rust-lang/rust-analyzer/releases/tag/2024-02-19 brings this bug, 2024-02-12 is working as expected.

theKidOfArcrania commented 5 months ago

Tracking issue for bug: https://github.com/rust-lang/rust-analyzer/issues/16607 seems to be fixed since very recently

theKidOfArcrania commented 5 months ago

I don't think, however, it actually properly fixes the bug tho

fannheyward commented 5 months ago

Made a quickfix in v0.75.2, to trim \\ for this case.

RustyYato commented 4 months ago

I'm still running into this issue if I generate multiple trait methods. I think the issue is because replace was used instead of replaceAll

fannheyward commented 4 months ago

@RustyYato try v0.75.3

RustyYato commented 4 months ago

That worked, thanks for the fast response!