From 3eb1952a6c01e87b9ed218ff2cbff246379c2f4a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 21 Oct 2025 00:43:33 +0300 Subject: [PATCH] Fix inlay hint cleanup on excerpts removal (#40738) A cherry-pick of https://github.com/zed-industries/zed/pull/40183/commits/f5188d55fbcbb3856038967bce8e824ddb42bdba This fixes a hard-to-reproduce crash caused excerpts removal not updating previous snapshot data after corresponding inlay data was removed. Same branch has a test: https://github.com/zed-industries/zed/pull/40183/commits/8783a9eb4fbc60e3fbe0654c2d330bddfaa7ef0a that does not fail on `main` due to different way inlays are queried, it will be merged later. Release Notes: - N/A --- crates/editor/src/display_map.rs | 8 ++++++-- crates/editor/src/editor.rs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 87841a8f7e135663df14b4bb82e18b61cf36907e..8d4894d9877f224ad96dc41b6cbd4311082c5038 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -594,7 +594,11 @@ impl DisplayMap { self.block_map.read(snapshot, edits); } - pub fn remove_inlays_for_excerpts(&mut self, excerpts_removed: &[ExcerptId]) { + pub fn remove_inlays_for_excerpts( + &mut self, + excerpts_removed: &[ExcerptId], + cx: &mut Context, + ) { let to_remove = self .inlay_map .current_inlays() @@ -606,7 +610,7 @@ impl DisplayMap { } }) .collect::>(); - self.inlay_map.splice(&to_remove, Vec::new()); + self.splice_inlays(&to_remove, Vec::new(), cx); } fn tab_size(buffer: &Entity, cx: &App) -> NonZeroU32 { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cfe21f1fae700103c65eb2f8d5bf5d570f84d3e0..4c7f17dd183ac1fe0fba2a5a6f99bf4915a31b6e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5291,8 +5291,8 @@ impl Editor { { self.splice_inlays(&to_remove, to_insert, cx); } - self.display_map.update(cx, |display_map, _| { - display_map.remove_inlays_for_excerpts(&excerpts_removed) + self.display_map.update(cx, |display_map, cx| { + display_map.remove_inlays_for_excerpts(&excerpts_removed, cx) }); return; }