Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Prevent panic in `lsp_symbols_at_cursor` with diff hunks handling (#51077)
Lukas Wirth3f2ddcbca327
diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rsindex 53fac7beac2..33cc1006792 100644--- a/crates/auto_update/src/auto_update.rs+++ b/crates/auto_update/src/auto_update.rs@@ -212,18 +212,10 @@ pub fn init(client: Arc<Client>, cx: &mut App) {}pub fn check(_: &Check, window: &mut Window, cx: &mut App) {- if let Some(message) = option_env!("ZED_UPDATE_EXPLANATION") {- drop(window.prompt(- gpui::PromptLevel::Info,- "Zed was installed via a package manager.",- Some(message),- &["Ok"],- cx,- ));- return;- }-- if let Ok(message) = env::var("ZED_UPDATE_EXPLANATION") {+ if let Some(message) = option_env!("ZED_UPDATE_EXPLANATION")+ .map(ToOwned::to_owned)+ .or_else(|| env::var("ZED_UPDATE_EXPLANATION").ok())+ {drop(window.prompt(gpui::PromptLevel::Info,"Zed was installed via a package manager.",diff --git a/crates/editor/src/document_symbols.rs b/crates/editor/src/document_symbols.rsindex 927ef346904..94d53eb1962 100644--- a/crates/editor/src/document_symbols.rs+++ b/crates/editor/src/document_symbols.rs@@ -77,6 +77,9 @@ impl Editor {let excerpt = multi_buffer_snapshot.excerpt_containing(cursor..cursor)?;let excerpt_id = excerpt.id();let buffer_id = excerpt.buffer_id();+ if Some(buffer_id) != cursor.text_anchor.buffer_id {+ return None;+ }let buffer = self.buffer.read(cx).buffer(buffer_id)?;let buffer_snapshot = buffer.read(cx).snapshot();let cursor_text_anchor = cursor.text_anchor;diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rsindex 5b599bad51c..04a38168dfa 100644--- a/crates/rope/src/rope.rs+++ b/crates/rope/src/rope.rs@@ -693,16 +693,21 @@ impl<'a> Cursor<'a> {}pub fn seek_forward(&mut self, end_offset: usize) {- debug_assert!(end_offset >= self.offset);+ assert!(+ end_offset >= self.offset,+ "cannot seek backward from {} to {}",+ self.offset,+ end_offset+ );self.chunks.seek_forward(&end_offset, Bias::Right);self.offset = end_offset;}pub fn slice(&mut self, end_offset: usize) -> Rope {- debug_assert!(+ assert!(end_offset >= self.offset,- "cannot slice backwards from {} to {}",+ "cannot slice backward from {} to {}",self.offset,end_offset);@@ -730,7 +735,12 @@ impl<'a> Cursor<'a> {}pub fn summary<D: TextDimension>(&mut self, end_offset: usize) -> D {- debug_assert!(end_offset >= self.offset);+ assert!(+ end_offset >= self.offset,+ "cannot summarize backward from {} to {}",+ self.offset,+ end_offset+ );let mut summary = D::zero(());if let Some(start_chunk) = self.chunks.item() {