From b69b5742eda00fcef9693d0131ac3282bf36837a Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 14 Nov 2023 11:27:52 -0700 Subject: [PATCH] Fix panicking unwrap() --- crates/command_palette2/src/command_palette.rs | 2 -- crates/gpui2/src/elements/div.rs | 3 --- crates/gpui2/src/elements/uniform_list.rs | 6 +++++- crates/gpui2/src/window.rs | 4 ---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/command_palette2/src/command_palette.rs b/crates/command_palette2/src/command_palette.rs index 5d428fba8e97ac306d2fe7ff54dea6e1ac0fdd37..435a6446693e590f2af9c678df445c0f53b18428 100644 --- a/crates/command_palette2/src/command_palette.rs +++ b/crates/command_palette2/src/command_palette.rs @@ -32,9 +32,7 @@ pub struct CommandPalette { impl CommandPalette { fn register(workspace: &mut Workspace, _: &mut ViewContext) { - dbg!("registering command palette toggle"); workspace.register_action(|workspace, _: &Toggle, cx| { - dbg!("got cmd-shift-p"); let Some(previous_focus_handle) = cx.focused() else { return; }; diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index 94f94241b219b74ac38c3322dfbccf63f6a77443..f3f6385503466387cbd992778203301eee40ad82 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -1076,9 +1076,6 @@ where }) } - if !self.key_context.is_empty() { - dbg!(&self.key_context, self.action_listeners.len()); - } for (action_type, listener) in self.action_listeners.drain(..) { cx.on_action(action_type, listener) } diff --git a/crates/gpui2/src/elements/uniform_list.rs b/crates/gpui2/src/elements/uniform_list.rs index 2f6584cda5b25599f8b916fb271b490824f36a27..28292a3d005e29b8009afabe836b34337912a875 100644 --- a/crates/gpui2/src/elements/uniform_list.rs +++ b/crates/gpui2/src/elements/uniform_list.rs @@ -193,7 +193,11 @@ impl Element for UniformList { }; let mut interactivity = mem::take(&mut self.interactivity); - let shared_scroll_offset = element_state.interactive.scroll_offset.clone().unwrap(); + let shared_scroll_offset = element_state + .interactive + .scroll_offset + .get_or_insert_with(Arc::default) + .clone(); interactivity.paint( bounds, diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index 3832605c3dd02c97d4f8e5b8c2895aafb2837ea3..00e050f2d85e8fa00146b16353da88baa550891c 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -1309,7 +1309,6 @@ impl<'a> WindowContext<'a> { .current_frame .dispatch_tree .dispatch_path(node_id); - dbg!(node_id, &dispatch_path, self.propagate_event); // Capture phase for node_id in &dispatch_path { @@ -1329,8 +1328,6 @@ impl<'a> WindowContext<'a> { } } - dbg!(node_id, &dispatch_path, self.propagate_event); - // Bubble phase for node_id in dispatch_path.iter().rev() { let node = self.window.current_frame.dispatch_tree.node(*node_id); @@ -1340,7 +1337,6 @@ impl<'a> WindowContext<'a> { } in node.action_listeners.clone() { let any_action = action.as_any(); - dbg!(action_type, any_action.type_id()); if action_type == any_action.type_id() { self.propagate_event = false; // Actions stop propagation by default during the bubble phase listener(any_action, DispatchPhase::Bubble, self);