Avoid sending unhandled LSP requests to JSON language server
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
0582c557e3
commit
81627a0f14
2 changed files with 32 additions and 1 deletions
|
@ -8,7 +8,7 @@ use language::{
|
|||
proto::{deserialize_anchor, serialize_anchor},
|
||||
range_from_lsp, Anchor, Bias, Buffer, PointUtf16, ToLspPosition, ToPointUtf16,
|
||||
};
|
||||
use lsp::DocumentHighlightKind;
|
||||
use lsp::{DocumentHighlightKind, ServerCapabilities};
|
||||
use std::{cmp::Reverse, ops::Range, path::Path};
|
||||
|
||||
#[async_trait(?Send)]
|
||||
|
@ -17,6 +17,10 @@ pub(crate) trait LspCommand: 'static + Sized {
|
|||
type LspRequest: 'static + Send + lsp::request::Request;
|
||||
type ProtoRequest: 'static + Send + proto::RequestMessage;
|
||||
|
||||
fn check_capabilities(&self, _: &lsp::ServerCapabilities) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn to_lsp(
|
||||
&self,
|
||||
path: &Path,
|
||||
|
@ -610,6 +614,10 @@ impl LspCommand for GetDocumentHighlights {
|
|||
type LspRequest = lsp::request::DocumentHighlightRequest;
|
||||
type ProtoRequest = proto::GetDocumentHighlights;
|
||||
|
||||
fn check_capabilities(&self, capabilities: &ServerCapabilities) -> bool {
|
||||
capabilities.document_highlight_provider.is_some()
|
||||
}
|
||||
|
||||
fn to_lsp(&self, path: &Path, _: &AppContext) -> lsp::DocumentHighlightParams {
|
||||
lsp::DocumentHighlightParams {
|
||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue