Fix bug preventing spaces from being used in filename (#3454)
This bug was my fault, something I changed months ago to be more consistent with VS Code - really strange that it took months for someone to find out spaces couldn't be used in the project panel. ~I didn't apply this fix to zed2 because I dont think the facilities are in place to do so (@maxbrunsfeld, @mikayla-maki, is there a system in place for this that I missed?). I did leave a TODO.~ Fix is now in zed 2. Release Notes: - Fixed a bug where spaces could not be inserted when editing file names in the project panel ([#2308](https://github.com/zed-industries/community/issues/2308)).
This commit is contained in:
commit
eef6c3729e
3 changed files with 39 additions and 6 deletions
|
@ -530,12 +530,17 @@
|
||||||
"alt-cmd-shift-c": "project_panel::CopyRelativePath",
|
"alt-cmd-shift-c": "project_panel::CopyRelativePath",
|
||||||
"f2": "project_panel::Rename",
|
"f2": "project_panel::Rename",
|
||||||
"enter": "project_panel::Rename",
|
"enter": "project_panel::Rename",
|
||||||
"space": "project_panel::Open",
|
|
||||||
"backspace": "project_panel::Delete",
|
"backspace": "project_panel::Delete",
|
||||||
"alt-cmd-r": "project_panel::RevealInFinder",
|
"alt-cmd-r": "project_panel::RevealInFinder",
|
||||||
"alt-shift-f": "project_panel::NewSearchInDirectory"
|
"alt-shift-f": "project_panel::NewSearchInDirectory"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"context": "ProjectPanel && not_editing",
|
||||||
|
"bindings": {
|
||||||
|
"space": "project_panel::Open"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"context": "CollabPanel && not_editing",
|
"context": "CollabPanel && not_editing",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
|
|
|
@ -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);
|
Self::reset_to_default_keymap_context(keymap);
|
||||||
keymap.add_identifier("menu");
|
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>) {
|
fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||||
|
|
|
@ -10,9 +10,9 @@ use anyhow::{anyhow, Result};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
|
actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
|
||||||
ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, Focusable, FocusableView,
|
ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, Focusable, FocusableView,
|
||||||
InteractiveElement, Model, MouseButton, MouseDownEvent, ParentElement, Pixels, Point,
|
InteractiveElement, KeyContext, Model, MouseButton, MouseDownEvent, ParentElement, Pixels,
|
||||||
PromptLevel, Render, Stateful, Styled, Subscription, Task, UniformListScrollHandle, View,
|
Point, PromptLevel, Render, Stateful, Styled, Subscription, Task, UniformListScrollHandle,
|
||||||
ViewContext, VisualContext as _, WeakView, WindowContext,
|
View, ViewContext, VisualContext as _, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::{
|
use project::{
|
||||||
|
@ -1420,6 +1420,22 @@ impl ProjectPanel {
|
||||||
// );
|
// );
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dispatch_context(&self, cx: &ViewContext<Self>) -> KeyContext {
|
||||||
|
let mut dispatch_context = KeyContext::default();
|
||||||
|
dispatch_context.add("ProjectPanel");
|
||||||
|
dispatch_context.add("menu");
|
||||||
|
|
||||||
|
let identifier = if self.filename_editor.focus_handle(cx).is_focused(cx) {
|
||||||
|
"editing"
|
||||||
|
} else {
|
||||||
|
"not_editing"
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch_context.add(identifier);
|
||||||
|
|
||||||
|
dispatch_context
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
|
@ -1433,7 +1449,7 @@ impl Render for ProjectPanel {
|
||||||
.id("project-panel")
|
.id("project-panel")
|
||||||
.size_full()
|
.size_full()
|
||||||
.relative()
|
.relative()
|
||||||
.key_context("ProjectPanel")
|
.key_context(self.dispatch_context(cx))
|
||||||
.on_action(cx.listener(Self::select_next))
|
.on_action(cx.listener(Self::select_next))
|
||||||
.on_action(cx.listener(Self::select_prev))
|
.on_action(cx.listener(Self::select_prev))
|
||||||
.on_action(cx.listener(Self::expand_selected_entry))
|
.on_action(cx.listener(Self::expand_selected_entry))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue