From 80f89059aabade8f83c35a371ba1cc3a713a5cd6 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 28 Oct 2024 12:55:55 -0700 Subject: [PATCH] Fix mouse clicks on remote-open-folder UI (#19851) Also change Zed's standard style to use `.track_focus(&self.focus_handle(cx))`, instead of `.track_focus(&self.focus_handle)`, to catch these kinds of errors more easily in the future. Release Notes: - N/A --------- Co-authored-by: Conrad --- crates/assistant/src/assistant_panel.rs | 2 +- crates/collab_ui/src/collab_panel.rs | 2 +- crates/copilot/src/sign_in.rs | 2 +- crates/diagnostics/src/diagnostics.rs | 2 +- crates/gpui/examples/input.rs | 4 ++-- crates/gpui/src/key_dispatch.rs | 2 +- crates/image_viewer/src/image_viewer.rs | 2 +- crates/markdown_preview/src/markdown_preview_view.rs | 2 +- crates/outline_panel/src/outline_panel.rs | 2 +- crates/picker/src/head.rs | 4 ++-- crates/project_panel/src/project_panel.rs | 4 ++-- crates/recent_projects/src/disconnected_overlay.rs | 2 +- crates/recent_projects/src/remote_servers.rs | 2 +- crates/search/src/project_search.rs | 4 ++-- crates/terminal_view/src/terminal_view.rs | 2 +- crates/ui/src/components/context_menu.rs | 2 +- crates/welcome/src/welcome.rs | 2 +- crates/workspace/src/dock.rs | 8 ++++---- crates/workspace/src/item.rs | 4 ++-- crates/workspace/src/pane.rs | 2 +- 20 files changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 479d63a76e..b15026c1ea 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -4707,7 +4707,7 @@ impl Render for ConfigurationView { let mut element = v_flex() .id("assistant-configuration-view") - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .bg(cx.theme().colors().editor_background) .size_full() .overflow_y_scroll() diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index f188aaf921..14cab63f63 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -2726,7 +2726,7 @@ impl Render for CollabPanel { .on_action(cx.listener(CollabPanel::collapse_selected_channel)) .on_action(cx.listener(CollabPanel::expand_selected_channel)) .on_action(cx.listener(CollabPanel::start_move_selected_channel)) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .size_full() .child(if self.user_store.read(cx).current_user().is_none() { self.render_signed_out(cx) diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index da6b969b72..d63710983b 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -185,7 +185,7 @@ impl Render for CopilotCodeVerification { v_flex() .id("copilot code verification") - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .elevation_3(cx) .w_96() .items_center() diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index cb6d07e906..cef634a41c 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -101,7 +101,7 @@ impl Render for ProjectDiagnosticsEditor { }; div() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .when(self.path_states.is_empty(), |el| { el.key_context("EmptyPane") }) diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 7e7de269b1..97c8b666c7 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -485,7 +485,7 @@ impl Render for TextInput { div() .flex() .key_context("TextInput") - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .cursor(CursorStyle::IBeam) .on_action(cx.listener(Self::backspace)) .on_action(cx.listener(Self::delete)) @@ -549,7 +549,7 @@ impl Render for InputExample { let num_keystrokes = self.recent_keystrokes.len(); div() .bg(rgb(0xaaaaaa)) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .flex() .flex_col() .size_full() diff --git a/crates/gpui/src/key_dispatch.rs b/crates/gpui/src/key_dispatch.rs index cb40a56367..722bc89a1d 100644 --- a/crates/gpui/src/key_dispatch.rs +++ b/crates/gpui/src/key_dispatch.rs @@ -16,7 +16,7 @@ /// impl Render for Editor { /// fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { /// div() -/// .track_focus(&self.focus_handle) +/// .track_focus(&self.focus_handle(cx)) /// .keymap_context("Editor") /// .on_action(cx.listener(Editor::undo)) /// .on_action(cx.listener(Editor::redo)) diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs index 607a4a4abe..1f6fb54d16 100644 --- a/crates/image_viewer/src/image_viewer.rs +++ b/crates/image_viewer/src/image_viewer.rs @@ -271,7 +271,7 @@ impl Render for ImageView { .left_0(); div() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .size_full() .child(checkered_background) .child( diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index 1aa60e2a3b..81145afa3f 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -479,7 +479,7 @@ impl Render for MarkdownPreviewView { v_flex() .id("MarkdownPreview") .key_context("MarkdownPreview") - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .size_full() .bg(cx.theme().colors().editor_background) .p_4() diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 6def76bb38..1259646a1b 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -3787,7 +3787,7 @@ impl Render for OutlinePanel { } }), ) - .track_focus(&self.focus_handle); + .track_focus(&self.focus_handle(cx)); if self.cached_entries.is_empty() { let header = if self.updating_fs_entries { diff --git a/crates/picker/src/head.rs b/crates/picker/src/head.rs index 1a103b252f..5ebcaf13a5 100644 --- a/crates/picker/src/head.rs +++ b/crates/picker/src/head.rs @@ -52,8 +52,8 @@ impl EmptyHead { } impl Render for EmptyHead { - fn render(&mut self, _: &mut ViewContext) -> impl IntoElement { - div().track_focus(&self.focus_handle) + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + div().track_focus(&self.focus_handle(cx)) } } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 355e8780cc..0df1062526 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -3136,7 +3136,7 @@ impl Render for ProjectPanel { } }), ) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .child( uniform_list(cx.view().clone(), "entries", item_count, { |this, range, cx| { @@ -3268,7 +3268,7 @@ impl Render for ProjectPanel { .id("empty-project_panel") .size_full() .p_4() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .child( Button::new("open_project", "Open a project") .full_width() diff --git a/crates/recent_projects/src/disconnected_overlay.rs b/crates/recent_projects/src/disconnected_overlay.rs index ed81fbb345..f176d56c51 100644 --- a/crates/recent_projects/src/disconnected_overlay.rs +++ b/crates/recent_projects/src/disconnected_overlay.rs @@ -149,7 +149,7 @@ impl Render for DisconnectedOverlay { }; div() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .elevation_3(cx) .on_action(cx.listener(Self::cancel)) .occlude() diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index a7ffee5e57..003485354e 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -1266,7 +1266,7 @@ impl Render for RemoteServerProjects { fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { self.selectable_items.reset(); div() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .elevation_3(cx) .w(rems(34.)) .key_context("RemoteServerModal") diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 1bc49551a7..b018f29693 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -327,7 +327,7 @@ impl Render for ProjectSearchView { div() .flex_1() .size_full() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .child(self.results_editor.clone()) } else { let model = self.model.read(cx); @@ -365,7 +365,7 @@ impl Render for ProjectSearchView { .size_full() .justify_center() .bg(cx.theme().colors().editor_background) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .child( h_flex() .size_full() diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index eed8c8123b..d192680968 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -975,7 +975,7 @@ impl Render for TerminalView { div() .size_full() .relative() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .key_context(self.dispatch_context(cx)) .on_action(cx.listener(TerminalView::send_text)) .on_action(cx.listener(TerminalView::send_keystroke)) diff --git a/crates/ui/src/components/context_menu.rs b/crates/ui/src/components/context_menu.rs index 92884b0182..702dd6a092 100644 --- a/crates/ui/src/components/context_menu.rs +++ b/crates/ui/src/components/context_menu.rs @@ -348,7 +348,7 @@ impl Render for ContextMenu { .min_w(px(200.)) .max_h(vh(0.75, cx)) .overflow_y_scroll() - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .on_mouse_down_out(cx.listener(|this, _, cx| this.cancel(&menu::Cancel, cx))) .key_context("menu") .on_action(cx.listener(ContextMenu::select_first)) diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rs index 1be2567c0a..0be48bd82e 100644 --- a/crates/welcome/src/welcome.rs +++ b/crates/welcome/src/welcome.rs @@ -72,7 +72,7 @@ impl Render for WelcomePage { h_flex() .size_full() .bg(cx.theme().colors().editor_background) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .child( v_flex() .w_80() diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 28c462fbfc..2317d02a5a 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -658,7 +658,7 @@ impl Render for Dock { div() .key_context(dispatch_context) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .flex() .bg(cx.theme().colors().panel_background) .border_color(cx.theme().colors().border) @@ -689,7 +689,7 @@ impl Render for Dock { } else { div() .key_context(dispatch_context) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) } } } @@ -826,8 +826,8 @@ pub mod test { } impl Render for TestPanel { - fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { - div().id("test").track_focus(&self.focus_handle) + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + div().id("test").track_focus(&self.focus_handle(cx)) } } diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 9dc0b957f8..2f1c900ecf 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -1173,8 +1173,8 @@ pub mod test { } impl Render for TestItem { - fn render(&mut self, _: &mut ViewContext) -> impl IntoElement { - gpui::div().track_focus(&self.focus_handle) + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + gpui::div().track_focus(&self.focus_handle(cx)) } } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 6b99401f05..01a1f0271e 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -2574,7 +2574,7 @@ impl Render for Pane { v_flex() .key_context(key_context) - .track_focus(&self.focus_handle) + .track_focus(&self.focus_handle(cx)) .size_full() .flex_none() .overflow_hidden()