From 955989431270443ca37955d55e97fa1e711fd870 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 5 Jun 2024 10:20:05 +0200 Subject: [PATCH] Add debug info to invalid offset error --- .../rust-analyzer/crates/rust-analyzer/src/lsp/from_proto.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/from_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/from_proto.rs index b6b20296d80a..60fe847bb7d8 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/from_proto.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/from_proto.rs @@ -37,8 +37,9 @@ pub(crate) fn offset( .ok_or_else(|| format_err!("Invalid wide col offset"))? } }; - let text_size = - line_index.index.offset(line_col).ok_or_else(|| format_err!("Invalid offset"))?; + let text_size = line_index.index.offset(line_col).ok_or_else(|| { + format_err!("Invalid offset {line_col:?} (line index length: {:?})", line_index.index.len()) + })?; Ok(text_size) }