Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use ESC to cancel dragging in Zed (#30318)
Kirill Bulatovb4fbb9bc0857
diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex e8eac4aaf6d..6faac7aff87 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -1463,7 +1463,9 @@ impl CollabPanel {}fn cancel(&mut self, _: &Cancel, window: &mut Window, cx: &mut Context<Self>) {- if self.take_editing_state(window, cx) {+ if cx.stop_active_drag(window) {+ return;+ } else if self.take_editing_state(window, cx) {window.focus(&self.filter_editor.focus_handle(cx));} else if !self.reset_filter_editor_text(window, cx) {self.focus_handle.focus(window);diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rsindex 4264568713a..17bdc42d12f 100644--- a/crates/debugger_ui/src/session/running.rs+++ b/crates/debugger_ui/src/session/running.rs@@ -352,6 +352,13 @@ pub(crate) fn new_debugger_pane(.px_2().border_color(cx.theme().colors().border).track_focus(&focus_handle)+ .on_action(|_: &menu::Cancel, window, cx| {+ if cx.stop_active_drag(window) {+ return;+ } else {+ cx.propagate();+ }+ }).child(h_flex().w_full()diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex 85f4c1a2687..5308428a198 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -1537,6 +1537,17 @@ impl App {self.active_drag.is_some()}+ /// Stops active drag and clears any related effects.+ pub fn stop_active_drag(&mut self, window: &mut Window) -> bool {+ if self.active_drag.is_some() {+ self.active_drag = None;+ window.refresh();+ true+ } else {+ false+ }+ }+/// Set the prompt renderer for GPUI. This will replace the default or platform specific/// prompts with this custom implementation.pub fn set_prompt_builder(diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex 9a65a8a0690..2d55fa0b5f5 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -1346,6 +1346,10 @@ impl ProjectPanel {}fn cancel(&mut self, _: &menu::Cancel, window: &mut Window, cx: &mut Context<Self>) {+ if cx.stop_active_drag(window) {+ return;+ }+let previous_edit_state = self.edit_state.take();self.update_visible_entries(None, cx);self.marked_entries.clear();diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 0040d45b201..2f452ef2e90 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -3326,6 +3326,13 @@ impl Render for Pane {}}),)+ .on_action(cx.listener(|_, _: &menu::Cancel, window, cx| {+ if cx.stop_active_drag(window) {+ return;+ } else {+ cx.propagate();+ }+ })).when(self.active_item().is_some() && display_tab_bar, |pane| {pane.child((self.render_tab_bar.clone())(self, window, cx))})diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex e82d305c21f..3c29f4f0ca7 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -5491,14 +5491,15 @@ impl Workspace {.ok();}- pub fn cancel(&mut self, _: &menu::Cancel, _: &mut Window, cx: &mut Context<Self>) {- if let Some((notification_id, _)) = self.notifications.pop() {- dismiss_app_notification(¬ification_id, cx);+ pub fn cancel(&mut self, _: &menu::Cancel, window: &mut Window, cx: &mut Context<Self>) {+ if cx.stop_active_drag(window) {return;+ } else if let Some((notification_id, _)) = self.notifications.pop() {+ dismiss_app_notification(¬ification_id, cx);+ } else {+ cx.emit(Event::ClearActivityIndicator);+ cx.propagate();}-- cx.emit(Event::ClearActivityIndicator);- cx.propagate();}}