Wait for LSP capabilities to be initialized before checking them
This commit is contained in:
parent
78d96a05fc
commit
3c242a43d2
1 changed files with 22 additions and 15 deletions
|
@ -22,7 +22,7 @@ use language::{
|
||||||
};
|
};
|
||||||
use lsp::{DiagnosticSeverity, DocumentHighlightKind, LanguageServer};
|
use lsp::{DiagnosticSeverity, DocumentHighlightKind, LanguageServer};
|
||||||
use lsp_command::*;
|
use lsp_command::*;
|
||||||
use postage::watch;
|
use postage::{prelude::Stream, watch};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use search::SearchQuery;
|
use search::SearchQuery;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
@ -1725,22 +1725,25 @@ impl Project {
|
||||||
return Task::ready(Ok(Default::default()));
|
return Task::ready(Ok(Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !lang_server
|
|
||||||
.capabilities()
|
|
||||||
.borrow()
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |capabilities| {
|
|
||||||
capabilities.code_action_provider.is_some()
|
|
||||||
})
|
|
||||||
{
|
|
||||||
return Task::ready(Ok(Default::default()));
|
|
||||||
}
|
|
||||||
|
|
||||||
let lsp_range = lsp::Range::new(
|
let lsp_range = lsp::Range::new(
|
||||||
range.start.to_point_utf16(buffer).to_lsp_position(),
|
range.start.to_point_utf16(buffer).to_lsp_position(),
|
||||||
range.end.to_point_utf16(buffer).to_lsp_position(),
|
range.end.to_point_utf16(buffer).to_lsp_position(),
|
||||||
);
|
);
|
||||||
cx.foreground().spawn(async move {
|
cx.foreground().spawn(async move {
|
||||||
|
let mut capabilities = lang_server.capabilities();
|
||||||
|
while capabilities.borrow().is_none() {
|
||||||
|
capabilities.recv().await;
|
||||||
|
}
|
||||||
|
if !capabilities
|
||||||
|
.borrow()
|
||||||
|
.as_ref()
|
||||||
|
.map_or(false, |capabilities| {
|
||||||
|
capabilities.code_action_provider.is_some()
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return Ok(Default::default());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(lang_server
|
Ok(lang_server
|
||||||
.request::<lsp::request::CodeActionRequest>(lsp::CodeActionParams {
|
.request::<lsp::request::CodeActionRequest>(lsp::CodeActionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
text_document: lsp::TextDocumentIdentifier::new(
|
||||||
|
@ -2263,12 +2266,16 @@ impl Project {
|
||||||
if let Some((file, language_server)) = file.zip(buffer.language_server().cloned()) {
|
if let Some((file, language_server)) = file.zip(buffer.language_server().cloned()) {
|
||||||
let lsp_params = request.to_lsp(&file.abs_path(cx), cx);
|
let lsp_params = request.to_lsp(&file.abs_path(cx), cx);
|
||||||
return cx.spawn(|this, cx| async move {
|
return cx.spawn(|this, cx| async move {
|
||||||
if !language_server
|
let mut capabilities = language_server.capabilities();
|
||||||
.capabilities()
|
while capabilities.borrow().is_none() {
|
||||||
|
capabilities.recv().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !capabilities
|
||||||
.borrow()
|
.borrow()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |capabilities| {
|
.map_or(false, |capabilities| {
|
||||||
request.check_capabilities(capabilities)
|
request.check_capabilities(&capabilities)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return Ok(Default::default());
|
return Ok(Default::default());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue