diff options
| author | bors <bors@rust-lang.org> | 2022-11-07 16:45:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-07 16:45:26 +0000 |
| commit | b8b1951ee8642e6fd8453ca437a081d2eb254d1c (patch) | |
| tree | 560ad0a34dc9d69a82707df32dd9b292ffa106fd | |
| parent | 0aa0da9dda7eaefe81b09f6e2f61b0bcff16a6be (diff) | |
| parent | 1cb6ab89eebb76953864b3d7fae8ed068fddc5a0 (diff) | |
| download | rust-b8b1951ee8642e6fd8453ca437a081d2eb254d1c.tar.gz rust-b8b1951ee8642e6fd8453ca437a081d2eb254d1c.zip | |
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
| -rw-r--r-- | crates/rust-analyzer/src/from_proto.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index 936957bab48..dd433b0f4d3 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -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> { |
