Move autosave logic up into Workspace
and Pane
This commit is contained in:
parent
980730a4e1
commit
b937c1acec
7 changed files with 166 additions and 132 deletions
|
@ -718,6 +718,18 @@ impl Pane {
|
|||
Ok(true)
|
||||
}
|
||||
|
||||
pub fn autosave_item(
|
||||
item: &dyn ItemHandle,
|
||||
project: ModelHandle<Project>,
|
||||
cx: &mut MutableAppContext,
|
||||
) -> Task<Result<()>> {
|
||||
if item.is_dirty(cx) && !item.has_conflict(cx) && item.can_save(cx) {
|
||||
item.save(project, cx)
|
||||
} else {
|
||||
Task::ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_active_item(&mut self, cx: &mut ViewContext<Self>) {
|
||||
if let Some(active_item) = self.active_item() {
|
||||
cx.focus(active_item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue