Respect server capabilities on queries (#33538)

Closes https://github.com/zed-industries/zed/issues/33522

Turns out a bunch of Zed requests were not checking their capabilities
correctly, due to odd copy-paste and due to default that assumed that
the capabilities are met.

Adjust the code, which includes the document colors, add the test on the
colors case.

Release Notes:

- Fixed excessive document colors requests for unrelated files
This commit is contained in:
Kirill Bulatov 2025-06-27 19:31:40 +03:00 committed by GitHub
parent f9987a1141
commit 01dfb6fa82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 259 additions and 74 deletions

View file

@ -16,7 +16,7 @@ use language::{
Buffer, point_to_lsp,
proto::{deserialize_anchor, serialize_anchor},
};
use lsp::{LanguageServer, LanguageServerId};
use lsp::{AdapterServerCapabilities, LanguageServer, LanguageServerId};
use rpc::proto::{self, PeerId};
use serde::{Deserialize, Serialize};
use std::{
@ -68,6 +68,10 @@ impl LspCommand for ExpandMacro {
"Expand macro"
}
fn check_capabilities(&self, _: AdapterServerCapabilities) -> bool {
true
}
fn to_lsp(
&self,
path: &Path,
@ -196,6 +200,10 @@ impl LspCommand for OpenDocs {
"Open docs"
}
fn check_capabilities(&self, _: AdapterServerCapabilities) -> bool {
true
}
fn to_lsp(
&self,
path: &Path,
@ -326,6 +334,10 @@ impl LspCommand for SwitchSourceHeader {
"Switch source header"
}
fn check_capabilities(&self, _: AdapterServerCapabilities) -> bool {
true
}
fn to_lsp(
&self,
path: &Path,
@ -404,6 +416,10 @@ impl LspCommand for GoToParentModule {
"Go to parent module"
}
fn check_capabilities(&self, _: AdapterServerCapabilities) -> bool {
true
}
fn to_lsp(
&self,
path: &Path,
@ -578,6 +594,10 @@ impl LspCommand for GetLspRunnables {
"LSP Runnables"
}
fn check_capabilities(&self, _: AdapterServerCapabilities) -> bool {
true
}
fn to_lsp(
&self,
path: &Path,