From 27d3da678cc1a0bd1686ebe47620d68a5c0ad4c1 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 3 Jun 2025 22:59:27 +0200 Subject: [PATCH] editor: Fix panic when full width crease is wrapped (#31960) Closes #31919 Release Notes: - Fixed a panic that could sometimes occur when the agent panel was too narrow and contained context included via `@`. --------- Co-authored-by: Antonio Co-authored-by: Antonio Scandurra --- crates/editor/src/display_map.rs | 11 ++++++++--- crates/editor/src/display_map/wrap_map.rs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 374f9ed0ba..a2fdb4c05c 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -2512,7 +2512,9 @@ pub mod tests { cx.update(|cx| syntax_chunks(DisplayRow(0)..DisplayRow(5), &map, &theme, cx)), [ ("fn \n".to_string(), None), - ("oute\nr".to_string(), Some(Hsla::blue())), + ("oute".to_string(), Some(Hsla::blue())), + ("\n".to_string(), None), + ("r".to_string(), Some(Hsla::blue())), ("() \n{}\n\n".to_string(), None), ] ); @@ -2535,8 +2537,11 @@ pub mod tests { [ ("out".to_string(), Some(Hsla::blue())), ("⋯\n".to_string(), None), - (" \nfn ".to_string(), Some(Hsla::red())), - ("i\n".to_string(), Some(Hsla::blue())) + (" ".to_string(), Some(Hsla::red())), + ("\n".to_string(), None), + ("fn ".to_string(), Some(Hsla::red())), + ("i".to_string(), Some(Hsla::blue())), + ("\n".to_string(), None) ] ); } diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index ca7ee056c4..fd662dbb1f 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -933,7 +933,7 @@ impl<'a> Iterator for WrapChunks<'a> { self.transforms.next(&()); return Some(Chunk { text: &display_text[start_ix..end_ix], - ..self.input_chunk.clone() + ..Default::default() }); }