Linked files: a change during a drag is applied after the drag, not lost (#1722)

This commit is contained in:
MarekSpodBiedry committed 2026-10-13 18:17:02 +02:00
1 parent 0d0ea352df
commit 65cc818572
2 files changed
+23

No files matched your search

+5
View File
@@ -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();
+18
View File
@@ -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);
}