Dismiss project panel's rename editor when it loses focus
This commit is contained in:
parent
2ab732efdb
commit
c1dfb6294b
1 changed files with 49 additions and 0 deletions
|
@ -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 {
|
let mut this = Self {
|
||||||
project: project.clone(),
|
project: project.clone(),
|
||||||
list: Default::default(),
|
list: Default::default(),
|
||||||
|
@ -1544,6 +1558,41 @@ mod tests {
|
||||||
" .dockerignore",
|
" .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(
|
fn toggle_expand_dir(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue