Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Remove redundant scopes and actions to fix the focus toggle on ESC

Kirill Bulatov18e0ee44a684
diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json
index d2fd4107e4f..01a09e0cba8 100644
--- a/assets/keymaps/default.json
+++ b/assets/keymaps/default.json
@@ -191,7 +191,7 @@
}
},
{
- "context": "BufferSearchBar > Editor",
+ "context": "BufferSearchBar",
"bindings": {
"escape": "buffer_search::Dismiss",
"tab": "buffer_search::FocusEditor",
@@ -200,13 +200,13 @@
}
},
{
- "context": "ProjectSearchBar > Editor",
+ "context": "ProjectSearchBar",
"bindings": {
"escape": "project_search::ToggleFocus"
}
},
{
- "context": "ProjectSearchView > Editor",
+ "context": "ProjectSearchView",
"bindings": {
"escape": "project_search::ToggleFocus"
}
diff --git a/crates/gpui/src/keymap_matcher/binding.rs b/crates/gpui/src/keymap_matcher/binding.rs
index aa40e8c6af5..4d8334128ba 100644
--- a/crates/gpui/src/keymap_matcher/binding.rs
+++ b/crates/gpui/src/keymap_matcher/binding.rs
@@ -11,6 +11,19 @@ pub struct Binding {
context_predicate: Option<KeymapContextPredicate>,
}
+impl std::fmt::Debug for Binding {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "Binding {{ keystrokes: {:?}, action: {}::{}, context_predicate: {:?} }}",
+ self.keystrokes,
+ self.action.namespace(),
+ self.action.name(),
+ self.context_predicate
+ )
+ }
+}
+
impl Clone for Binding {
fn clone(&self) -> Self {
Self {
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs
index 8a62a28c113..6350b43415e 100644
--- a/crates/workspace/src/workspace.rs
+++ b/crates/workspace/src/workspace.rs
@@ -234,7 +234,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
},
);
cx.add_action(Workspace::toggle_sidebar_item);
- cx.add_action(Workspace::focus_center);
cx.add_action(|workspace: &mut Workspace, _: &ActivatePreviousPane, cx| {
workspace.activate_previous_pane(cx)
});
@@ -1415,11 +1414,6 @@ impl Workspace {
cx.notify();
}
- pub fn focus_center(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
- cx.focus_self();
- cx.notify();
- }
-
fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> ViewHandle<Pane> {
let pane = cx.add_view(|cx| {
Pane::new(