Skip to content

Commit

Permalink
Auto merge of rust-lang#13573 - Veykril:invalid-file-range, r=Veykril
Browse files Browse the repository at this point in the history
internal: error instead of panic on invalid file range

Fixes the panic in rust-lang/rust-analyzer#13170
  • Loading branch information
bors committed Nov 7, 2022
2 parents 0aa0da9 + 1cb6ab8 commit b8b1951
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/rust-analyzer/src/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
let start = offset(line_index, range.start)?;
let end = offset(line_index, range.end)?;
let text_range = TextRange::new(start, end);
Ok(text_range)
match end < start {
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> {
Expand Down

0 comments on commit b8b1951

Please sign in to comment.