mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-28 12:55:11 +00:00
Auto merge of #13573 - Veykril:invalid-file-range, r=Veykril
internal: error instead of panic on invalid file range Fixes the panic in https://github.com/rust-lang/rust-analyzer/issues/13170
This commit is contained in:
commit
b8b1951ee8
1 changed files with 4 additions and 2 deletions
|
@ -42,8 +42,10 @@ pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> R
|
||||||
pub(crate) fn text_range(line_index: &LineIndex, range: lsp_types::Range) -> Result<TextRange> {
|
pub(crate) fn text_range(line_index: &LineIndex, range: lsp_types::Range) -> Result<TextRange> {
|
||||||
let start = offset(line_index, range.start)?;
|
let start = offset(line_index, range.start)?;
|
||||||
let end = offset(line_index, range.end)?;
|
let end = offset(line_index, range.end)?;
|
||||||
let text_range = TextRange::new(start, end);
|
match end < start {
|
||||||
Ok(text_range)
|
true => Err(format_err!("Invalid Range").into()),
|
||||||
|
false => Ok(TextRange::new(start, end)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn file_id(snap: &GlobalStateSnapshot, url: &lsp_types::Url) -> Result<FileId> {
|
pub(crate) fn file_id(snap: &GlobalStateSnapshot, url: &lsp_types::Url) -> Result<FileId> {
|
||||||
|
|
Loading…
Reference in a new issue