Use ESC to cancel dragging in Zed (#30318)

Closes https://github.com/zed-industries/zed/issues/11887

ESC is always captured in terminal due to 


980bfae331/crates/terminal/src/terminal.rs (L1339-L1353)

so this part is not fixed.

Otherwise, all other drags are cancelled when ESC is pressed:


https://github.com/user-attachments/assets/6e70a1e5-c244-420b-9dec-ae2ac2997a59


Release Notes:

- Allowed to use ESC to cancel dragging in Zed
This commit is contained in:
Kirill Bulatov 2025-05-09 01:58:38 +03:00 committed by GitHub
parent 83378b856f
commit b4fbb9bc08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 39 additions and 7 deletions

View file

@ -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))
})

View file

@ -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(&notification_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(&notification_id, cx);
} else {
cx.emit(Event::ClearActivityIndicator);
cx.propagate();
}
cx.emit(Event::ClearActivityIndicator);
cx.propagate();
}
}