From 1751bf4cdbe8b6a55546d290c7f2a0f47721b041 Mon Sep 17 00:00:00 2001 From: "Mitch (a.k.a Voz)" Date: Tue, 9 Sep 2025 14:26:35 -0500 Subject: [PATCH] Allow outline modal toggling (#37575) Closes #37511 The outline modal seems to have a bug where if it's open and the `outline::Toggle` is triggered, it would not close if there was another command with the same keybind. So instead, if the outline modal is open and an `outline::Toggle` is triggered, we dismiss the modal. Release Notes: - Fixed a bug where `outline::Toggle` would sometimes not close outline modal --- crates/outline/src/outline.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 8c5e78d77bce76e62ef94d2501dbef588cd76f00..1f85d08cee850f18a30cca9b56061854f7cbc7b1 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -81,8 +81,19 @@ impl ModalView for OutlineView { } impl Render for OutlineView { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - v_flex().w(rems(34.)).child(self.picker.clone()) + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + v_flex() + .w(rems(34.)) + .on_action(cx.listener( + |_this: &mut OutlineView, + _: &zed_actions::outline::ToggleOutline, + _window: &mut Window, + cx: &mut Context| { + // When outline::Toggle is triggered while the outline is open, dismiss it + cx.emit(DismissEvent); + }, + )) + .child(self.picker.clone()) } }