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

Typing text offsets diagnostics that are after text typed #701

Closed
Omnikar opened this issue Sep 3, 2021 · 8 comments · Fixed by #6447
Closed

Typing text offsets diagnostics that are after text typed #701

Omnikar opened this issue Sep 3, 2021 · 8 comments · Fixed by #6447
Labels
A-language-server Area: Language server client C-bug Category: This is a bug upstream

Comments

@Omnikar
Copy link
Contributor

Omnikar commented Sep 3, 2021

https://asciinema.org/a/8zyizvoNTUMkDhhzeaS10qw0W

I presume this is probably because of char indexing for the diagnostics.

@Omnikar Omnikar added the C-bug Category: This is a bug label Sep 3, 2021
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Sep 3, 2021
@archseer
Copy link
Member

archseer commented Sep 4, 2021

I did initially map diagnostics through edits to prevent this (updating the positions), but I noticed that rust-analyzer would unhelpfully re-send the wrong offsets immediately, undoing the work.

@archseer
Copy link
Member

archseer commented Sep 4, 2021

(It'll fix the positions after you save and it re-runs the checks)

@archseer
Copy link
Member

archseer commented Sep 4, 2021

Commented out code:

// map state.diagnostics over changes::map_pos too
// NOTE: seems to do nothing since the language server resends diagnostics on each edit
// for diagnostic in &mut self.diagnostics {
// use helix_core::Assoc;
// let changes = transaction.changes();
// diagnostic.range.start = changes.map_pos(diagnostic.range.start, Assoc::After);
// diagnostic.range.end = changes.map_pos(diagnostic.range.end, Assoc::After);
// diagnostic.line = self.text.char_to_line(diagnostic.range.start);
// }

@kirawi kirawi added A-language-server Area: Language server client and removed A-helix-term Area: Helix term improvements labels Sep 4, 2021
@kirawi
Copy link
Member

kirawi commented Sep 11, 2021

Is there anything that can be done about it?

@kirawi
Copy link
Member

kirawi commented Oct 24, 2021

Looks like we're not getting PublishDiagnosticsParams w/ any whitespace (including comments).

@archseer
Copy link
Member

archseer commented Nov 3, 2021

Turns out this is a known rust-analyzer issue: rust-lang/rust-analyzer#8836

@kirawi kirawi closed this as completed Dec 6, 2021
@archseer archseer reopened this Dec 6, 2021
@gabydd
Copy link
Member

gabydd commented Dec 18, 2022

correct me if I am wrong but I think this is fixed on master

@the-mikedavis
Copy link
Member

I think this still happens unless it was fixed in a recent rust-analyzer version. From what I understand this is caused by rust-analyzer sending out-of-date/cached ranges in publishDiagnostic which undoes the work we do within helix for updating ranges rust-lang/rust-analyzer#10628 (comment)

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 upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants