mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Dismiss project panel's rename editor when it loses focus
This commit is contained in:
parent
2ab732efdb
commit
c1dfb6294b
@ -184,6 +184,20 @@ impl ProjectPanel {
|
||||
)
|
||||
});
|
||||
|
||||
cx.observe_focus(&filename_editor, |this, _, is_focused, cx| {
|
||||
if !is_focused {
|
||||
if this
|
||||
.edit_state
|
||||
.as_ref()
|
||||
.map_or(false, |state| state.processing_filename.is_none())
|
||||
{
|
||||
this.edit_state = None;
|
||||
this.update_visible_entries(None, cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
let mut this = Self {
|
||||
project: project.clone(),
|
||||
list: Default::default(),
|
||||
@ -1544,6 +1558,41 @@ mod tests {
|
||||
" .dockerignore",
|
||||
]
|
||||
);
|
||||
|
||||
panel.update(cx, |panel, cx| panel.rename(&Default::default(), cx));
|
||||
assert_eq!(
|
||||
visible_entries_as_strings(&panel, 0..10, cx),
|
||||
&[
|
||||
"v root1",
|
||||
" > .git",
|
||||
" > a",
|
||||
" v b",
|
||||
" > [EDITOR: '3'] <== selected",
|
||||
" > 4",
|
||||
" > new-dir",
|
||||
" a-different-filename",
|
||||
" > C",
|
||||
" .dockerignore",
|
||||
]
|
||||
);
|
||||
|
||||
// Dismiss the rename editor when it loses focus.
|
||||
workspace.update(cx, |_, cx| cx.focus_self());
|
||||
assert_eq!(
|
||||
visible_entries_as_strings(&panel, 0..10, cx),
|
||||
&[
|
||||
"v root1",
|
||||
" > .git",
|
||||
" > a",
|
||||
" v b",
|
||||
" > 3 <== selected",
|
||||
" > 4",
|
||||
" > new-dir",
|
||||
" a-different-filename",
|
||||
" > C",
|
||||
" .dockerignore",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
fn toggle_expand_dir(
|
||||
|
Loading…
Reference in New Issue
Block a user