Be more lenient when dealing with rust-analyzer's flycheck commands (#36782)

Flycheck commands are global and makes sense to fall back to looking up
project's rust-analyzer even if the commands are run on a non-rust
buffer. If multiple rust-analyzers are found in the project, avoid
ambiguous commands and bail (as before).

Closes #ISSUE

Release Notes:

- Made it possible to run rust-analyzer's flycheck actions from anywhere
in the project
This commit is contained in:
Kirill Bulatov 2025-08-23 01:55:50 +03:00 committed by GitHub
parent 153724aad3
commit d24cad30f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 114 additions and 64 deletions

View file

@ -9029,13 +9029,22 @@ impl LspStore {
lsp_store.update(&mut cx, |lsp_store, cx| {
if let Some(server) = lsp_store.language_server_for_id(server_id) {
let text_document = if envelope.payload.current_file_only {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
lsp_store
.buffer_store()
.read(cx)
.get(buffer_id)
.and_then(|buffer| Some(buffer.read(cx).file()?.as_local()?.abs_path(cx)))
.map(|path| make_text_document_identifier(&path))
let buffer_id = envelope
.payload
.buffer_id
.map(|id| BufferId::new(id))
.transpose()?;
buffer_id
.and_then(|buffer_id| {
lsp_store
.buffer_store()
.read(cx)
.get(buffer_id)
.and_then(|buffer| {
Some(buffer.read(cx).file()?.as_local()?.abs_path(cx))
})
.map(|path| make_text_document_identifier(&path))
})
.transpose()?
} else {
None