Add validation in LspCommand::to_lsp
+ check for inverted ranges (#22731)
#22690 logged errors and flipped the range in this case. Instead it brings more visibility to the issue to return errors. Release Notes: - N/A
This commit is contained in:
parent
1c223d8940
commit
141393232e
6 changed files with 134 additions and 162 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{lsp_command::LspCommand, lsp_store::LspStore};
|
||||
use crate::{lsp_command::LspCommand, lsp_store::LspStore, make_text_document_identifier};
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use gpui::{AppContext, AsyncAppContext, Model};
|
||||
|
@ -53,13 +53,11 @@ impl LspCommand for ExpandMacro {
|
|||
_: &Buffer,
|
||||
_: &Arc<LanguageServer>,
|
||||
_: &AppContext,
|
||||
) -> ExpandMacroParams {
|
||||
ExpandMacroParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: lsp::Url::from_file_path(path).unwrap(),
|
||||
},
|
||||
) -> Result<ExpandMacroParams> {
|
||||
Ok(ExpandMacroParams {
|
||||
text_document: make_text_document_identifier(path)?,
|
||||
position: point_to_lsp(self.position),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn response_from_lsp(
|
||||
|
@ -179,13 +177,13 @@ impl LspCommand for OpenDocs {
|
|||
_: &Buffer,
|
||||
_: &Arc<LanguageServer>,
|
||||
_: &AppContext,
|
||||
) -> OpenDocsParams {
|
||||
OpenDocsParams {
|
||||
) -> Result<OpenDocsParams> {
|
||||
Ok(OpenDocsParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: lsp::Url::from_file_path(path).unwrap(),
|
||||
},
|
||||
position: point_to_lsp(self.position),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn response_from_lsp(
|
||||
|
@ -292,10 +290,10 @@ impl LspCommand for SwitchSourceHeader {
|
|||
_: &Buffer,
|
||||
_: &Arc<LanguageServer>,
|
||||
_: &AppContext,
|
||||
) -> SwitchSourceHeaderParams {
|
||||
SwitchSourceHeaderParams(lsp::TextDocumentIdentifier {
|
||||
uri: lsp::Url::from_file_path(path).unwrap(),
|
||||
})
|
||||
) -> Result<SwitchSourceHeaderParams> {
|
||||
Ok(SwitchSourceHeaderParams(make_text_document_identifier(
|
||||
path,
|
||||
)?))
|
||||
}
|
||||
|
||||
async fn response_from_lsp(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue