mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Linked files: a change during a drag is applied after the drag, not lost (#1722)
This commit is contained in:
1 parent
0d0ea352df
commit
65cc818572
2 files changed
+23
No files matched your search
@@ -97,6 +97,11 @@ impl Session {
|
||||
if self.active().map(|d| d.uid) != Some(uid) {
|
||||
return Ok(none());
|
||||
}
|
||||
// A drag is in progress: its next preview or cancel would throw an update away while the new
|
||||
// stamp stayed recorded. Leave the stamps alone; the first look after the drag sees the change.
|
||||
if self.in_interaction() {
|
||||
return Ok(none());
|
||||
}
|
||||
// This document's last stamps; those of closed documents are dropped.
|
||||
let open: HashSet<u64> = self.documents().iter().map(|d| d.uid).collect();
|
||||
let mut before: HashMap<String, Stamp> = HashMap::new();
|
||||
|
||||
@@ -86,3 +86,21 @@ fn a_file_still_being_written_is_tried_again() {
|
||||
assert_eq!(look(&mut s)["updated"], json!([id.0]));
|
||||
assert_eq!(colour(&s), BLUE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_change_during_a_drag_waits_for_the_drag_to_end() {
|
||||
let dir = Folder::new("watch-drag");
|
||||
let path = dir.file("art.png");
|
||||
std::fs::write(&path, png(40, 40, RED)).unwrap();
|
||||
let mut s = session();
|
||||
s.prefs.update_links = "automatically".into();
|
||||
let id = place(&mut s, &path);
|
||||
look(&mut s);
|
||||
s.begin_interaction("Move").unwrap();
|
||||
save(&path, &png(40, 40, BLUE));
|
||||
// The preview would throw the update away, so it is not applied (nor its stamp kept).
|
||||
assert_eq!(look(&mut s), json!({"updated": [], "ask": [], "modified": []}));
|
||||
s.cancel_interaction().unwrap();
|
||||
assert_eq!(look(&mut s)["updated"], json!([id.0]));
|
||||
assert_eq!(colour(&s), BLUE);
|
||||
}
|
||||
Reference in new issue
Block a user