Fix bug preventing spaces from being used in filename

Joseph T. Lyons created

Change summary

assets/keymaps/default.json                |  7 ++++++-
crates/project_panel/src/project_panel.rs  | 14 +++++++++++++-
crates/project_panel2/src/project_panel.rs | 18 ++++++++++++++++++
3 files changed, 37 insertions(+), 2 deletions(-)

Detailed changes

assets/keymaps/default.json 🔗

@@ -530,12 +530,17 @@
       "alt-cmd-shift-c": "project_panel::CopyRelativePath",
       "f2": "project_panel::Rename",
       "enter": "project_panel::Rename",
-      "space": "project_panel::Open",
       "backspace": "project_panel::Delete",
       "alt-cmd-r": "project_panel::RevealInFinder",
       "alt-shift-f": "project_panel::NewSearchInDirectory"
     }
   },
+  {
+    "context": "ProjectPanel && not_editing",
+    "bindings": {
+      "space": "project_panel::Open"
+    }
+  },
   {
     "context": "CollabPanel && not_editing",
     "bindings": {

crates/project_panel/src/project_panel.rs 🔗

@@ -1627,9 +1627,21 @@ impl View for ProjectPanel {
         }
     }
 
-    fn update_keymap_context(&self, keymap: &mut KeymapContext, _: &AppContext) {
+    fn update_keymap_context(&self, keymap: &mut KeymapContext, cx: &AppContext) {
         Self::reset_to_default_keymap_context(keymap);
         keymap.add_identifier("menu");
+
+        if let Some(window) = cx.active_window() {
+            window.read_with(cx, |cx| {
+                let identifier = if self.filename_editor.is_focused(cx) {
+                    "editing"
+                } else {
+                    "not_editing"
+                };
+
+                keymap.add_identifier(identifier);
+            });
+        }
     }
 
     fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {

crates/project_panel2/src/project_panel.rs 🔗

@@ -3011,3 +3011,21 @@ mod tests {
             .unwrap();
     }
 }
+
+// TODO - implement this in the new keymap system
+// fn update_keymap_context(&self, keymap: &mut KeymapContext, cx: &AppContext) {
+//     Self::reset_to_default_keymap_context(keymap);
+//     keymap.add_identifier("menu");
+
+//     if let Some(window) = cx.active_window() {
+//         window.read_with(cx, |cx| {
+//             let identifier = if self.filename_editor.is_focused(cx) {
+//                 "editing"
+//             } else {
+//                 "not_editing"
+//             };
+
+//             keymap.add_identifier(identifier);
+//         });
+//     }
+// }