ElyDoc: a hidden navigator reads nothing on each cursor move (D-07)
This commit is contained in:
3 files changed
+27
-2
No files matched your search
@@ -80,7 +80,8 @@ impl Docs {
|
||||
let shown = self
|
||||
.active_tab()
|
||||
.map(|tab| (tab.view.clone(), tab.doc.clone()));
|
||||
let tab = shown.as_ref().map(|(view, doc)| (view, doc));
|
||||
// Hidden, it follows nothing: no reads on every move.
|
||||
let tab = shown.as_ref().filter(|_| self.navigating).map(|(view, doc)| (view, doc));
|
||||
self.navigator
|
||||
.update(cx, |navigator, cx| navigator.show(tab, cx));
|
||||
shown.filter(|_| self.navigating)?;
|
||||
|
||||
@@ -253,6 +253,30 @@ fn pdfs_export_a_range_and_locked_files_ask() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hidden_navigator_reads_nothing() {
|
||||
let dir = tempfile::tempdir().expect("a temp dir");
|
||||
let mut cx = TestAppContext::single();
|
||||
let Some(docs) = docs(&mut cx, dir.path()) else {
|
||||
eprintln!("SKIP: no LOK build");
|
||||
return;
|
||||
};
|
||||
crate::tests::blank(&mut cx, &docs);
|
||||
let follows = |cx: &mut TestAppContext| cx.update(|app| docs.read(app).navigator.read(app).shown.is_some());
|
||||
cx.update(|app| docs.update(app, |docs, cx| docs.left_view(cx)));
|
||||
assert!(follows(&mut cx), "shown: it follows the tab");
|
||||
cx.update(|app| docs.update(app, |docs, cx| {
|
||||
docs.navigating = false;
|
||||
docs.left_view(cx)
|
||||
}));
|
||||
assert!(!follows(&mut cx), "hidden: no tab to reread");
|
||||
cx.update(|app| docs.update(app, |docs, cx| {
|
||||
docs.navigating = true;
|
||||
docs.left_view(cx)
|
||||
}));
|
||||
assert!(follows(&mut cx), "shown again: it reads once more");
|
||||
}
|
||||
|
||||
/// The navigator alone as a window's view.
|
||||
struct Host(Entity<Navigator>);
|
||||
|
||||
|
||||
Reference in new issue
Block a user