mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Merge pull request #1391 from zed-industries/dismiss-project-panel-rename
Dismiss project panel's rename editor when it loses focus
This commit is contained in:
commit
1a1ec1b81a
@ -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…
Reference in New Issue
Block a user