Update window edited status when pane item is removed
This commit is contained in:
parent
2dae0ddcdb
commit
a21dbdd0d6
4 changed files with 11 additions and 3 deletions
|
@ -22,7 +22,7 @@ use smallvec::SmallVec;
|
||||||
use smol::prelude::*;
|
use smol::prelude::*;
|
||||||
use std::{
|
use std::{
|
||||||
any::{type_name, Any, TypeId},
|
any::{type_name, Any, TypeId},
|
||||||
cell::{RefCell, RefMut},
|
cell::RefCell,
|
||||||
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
|
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
@ -567,8 +567,8 @@ impl TestAppContext {
|
||||||
.assert_dropped(handle.id())
|
.assert_dropped(handle.id())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_mut(&self, window_id: usize) -> RefMut<platform::test::Window> {
|
fn window_mut(&self, window_id: usize) -> std::cell::RefMut<platform::test::Window> {
|
||||||
RefMut::map(self.cx.borrow_mut(), |state| {
|
std::cell::RefMut::map(self.cx.borrow_mut(), |state| {
|
||||||
let (_, window) = state
|
let (_, window) = state
|
||||||
.presenters_and_platform_windows
|
.presenters_and_platform_windows
|
||||||
.get_mut(&window_id)
|
.get_mut(&window_id)
|
||||||
|
|
|
@ -110,6 +110,7 @@ pub enum Event {
|
||||||
Activate,
|
Activate,
|
||||||
ActivateItem { local: bool },
|
ActivateItem { local: bool },
|
||||||
Remove,
|
Remove,
|
||||||
|
RemoveItem,
|
||||||
Split(SplitDirection),
|
Split(SplitDirection),
|
||||||
ChangeItemTitle,
|
ChangeItemTitle,
|
||||||
}
|
}
|
||||||
|
@ -575,6 +576,7 @@ impl Pane {
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = pane.items.remove(item_ix);
|
let item = pane.items.remove(item_ix);
|
||||||
|
cx.emit(Event::RemoveItem);
|
||||||
if pane.items.is_empty() {
|
if pane.items.is_empty() {
|
||||||
item.deactivated(cx);
|
item.deactivated(cx);
|
||||||
pane.update_toolbar(cx);
|
pane.update_toolbar(cx);
|
||||||
|
|
|
@ -1482,6 +1482,9 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
self.update_window_edited(cx);
|
self.update_window_edited(cx);
|
||||||
}
|
}
|
||||||
|
pane::Event::RemoveItem => {
|
||||||
|
self.update_window_edited(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!("pane {} not found", pane_id);
|
error!("pane {} not found", pane_id);
|
||||||
|
|
|
@ -462,7 +462,10 @@ mod tests {
|
||||||
.downcast::<Editor>()
|
.downcast::<Editor>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
assert!(!cx.is_window_edited(workspace.window_id()));
|
||||||
|
|
||||||
editor.update(cx, |editor, cx| editor.insert("EDIT", cx));
|
editor.update(cx, |editor, cx| editor.insert("EDIT", cx));
|
||||||
|
assert!(cx.is_window_edited(workspace.window_id()));
|
||||||
|
|
||||||
assert!(!cx.simulate_window_close(workspace.window_id()));
|
assert!(!cx.simulate_window_close(workspace.window_id()));
|
||||||
executor.run_until_parked();
|
executor.run_until_parked();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue