Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix expand/collapse all button for splittable editor (#50859)
Dinofbeffc4f37d1
diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rsindex b3511915be4..4e5f8ebf279 100644--- a/crates/editor/src/split.rs+++ b/crates/editor/src/split.rs@@ -1857,6 +1857,21 @@ impl Item for SplittableEditor {fn pixel_position_of_cursor(&self, cx: &App) -> Option<gpui::Point<gpui::Pixels>> {self.focused_editor().read(cx).pixel_position_of_cursor(cx)}++ fn act_as_type<'a>(+ &'a self,+ type_id: std::any::TypeId,+ self_handle: &'a Entity<Self>,+ _: &'a App,+ ) -> Option<gpui::AnyEntity> {+ if type_id == std::any::TypeId::of::<Self>() {+ Some(self_handle.clone().into())+ } else if type_id == std::any::TypeId::of::<Editor>() {+ Some(self.rhs_editor.clone().into())+ } else {+ None+ }+ }}impl SearchableItem for SplittableEditor {@@ -2064,7 +2079,7 @@ impl Render for SplittableEditor {#[cfg(test)]mod tests {- use std::sync::Arc;+ use std::{any::TypeId, sync::Arc};use buffer_diff::BufferDiff;use collections::{HashMap, HashSet};@@ -2080,14 +2095,14 @@ mod tests {use settings::{DiffViewStyle, SettingsStore};use ui::{VisualContext as _, div, px};use util::rel_path::rel_path;- use workspace::MultiWorkspace;+ use workspace::{Item, MultiWorkspace};- use crate::SplittableEditor;use crate::display_map::{BlockPlacement, BlockProperties, BlockStyle, Crease, FoldPlaceholder,};use crate::inlays::Inlay;use crate::test::{editor_content_with_blocks_and_width, set_block_content_for_tests};+ use crate::{Editor, SplittableEditor};use multi_buffer::MultiBufferOffset;async fn init_test(@@ -6025,4 +6040,17 @@ mod tests {cx.run_until_parked();}++ #[gpui::test]+ async fn test_act_as_type(cx: &mut gpui::TestAppContext) {+ let (splittable_editor, cx) = init_test(cx, SoftWrap::None, DiffViewStyle::Split).await;+ let editor = splittable_editor.read_with(cx, |editor, cx| {+ editor.act_as_type(TypeId::of::<Editor>(), &splittable_editor, cx)+ });++ assert!(+ editor.is_some(),+ "SplittableEditor should be able to act as Editor"+ );+ }}