editor: Refactor excerpts removed event handling (#50695)

Refactor the changes introduced in
https://github.com/zed-industries/zed/pull/50525, in order to remove the
`DisplayMap.clear_folded_buffer` method and update the editor's handling
of `multi_buffer::Event::ExcerptsRemoved` to actually call
`DisplayMap.unfold_buffers`, which correctly updates the `BlockMap`
using its `BlockMapWriter`, ensuring that the block map is synced.

Before you mark this PR as ready for review, make sure that you have:
- [X] Added a solid test coverage and/or screenshots from doing manual
testing
- [X] Done a self-review taking into account security and performance
aspects
- [X] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
This commit is contained in:
Dino authored and GitHub committed 2026-03-04 13:11:40 +01:00
1 parent 31dcfded35
commit 97cfc94694
2 files changed
+5 -6

No files matched your search

-5
View File
@@ -1006,11 +1006,6 @@ impl DisplayMap {
&self.block_map.folded_buffers
}
#[instrument(skip_all)]
pub(super) fn clear_folded_buffer(&mut self, buffer_id: language::BufferId) {
self.block_map.folded_buffers.remove(&buffer_id);
}
#[instrument(skip_all)]
pub fn insert_creases(
&mut self,
+5 -1
View File
@@ -24147,9 +24147,13 @@ impl Editor {
self.display_map.update(cx, |display_map, cx| {
display_map.invalidate_semantic_highlights(*buffer_id);
display_map.clear_lsp_folding_ranges(*buffer_id, cx);
display_map.clear_folded_buffer(*buffer_id);
});
}
self.display_map.update(cx, |display_map, cx| {
display_map.unfold_buffers(removed_buffer_ids.iter().copied(), cx);
});
jsx_tag_auto_close::refresh_enabled_in_any_buffer(self, multibuffer, cx);
cx.emit(EditorEvent::ExcerptsRemoved {
ids: ids.clone(),