fix: preserve review comments across unrelated edits

This commit is contained in:
Valdemar Lorenzen
2026-10-20 14:58:56 +02:00
parent 2727425518
commit 31203889bb
10 changed files with 422 additions and 147 deletions
+7 -7
View File
@@ -2895,15 +2895,15 @@ fn review_anchors_match_frozen_context_and_exact_live_eof_without_allocating() {
end: crate::plugin::TextPosition { row: 1, column: 0 },
content: "new\n".into(),
};
assert!(state.review_anchor_current(&anchor));
assert!(state.review_anchor_range(&anchor).is_some());
state.live_files.insert(0);
assert!(!state.review_anchor_current(&anchor));
assert!(state.review_anchor_range(&anchor).is_none());
state.comparison.as_mut().unwrap().files[0]
.after
.push(String::new());
assert!(state.review_anchor_current(&anchor));
assert!(state.review_anchor_range(&anchor).is_some());
state.comparison.as_mut().unwrap().files[0].after[0] = "changed".into();
assert!(!state.review_anchor_current(&anchor));
assert!(state.review_anchor_range(&anchor).is_none());
state.comparison.as_mut().unwrap().files[0].old_path = Some("original".into());
let before = Anchor {
revision: "base".into(),
@@ -2912,12 +2912,12 @@ fn review_anchors_match_frozen_context_and_exact_live_eof_without_allocating() {
content: "old\n".into(),
..anchor
};
assert!(state.review_anchor_current(&before));
assert!(state.review_anchor_range(&before).is_some());
state.comparison.as_mut().unwrap().files[0].loaded = false;
assert!(!state.review_anchor_current(&before));
assert!(state.review_anchor_range(&before).is_none());
state.comparison.as_mut().unwrap().files[0].loaded = true;
state.comparison.as_mut().unwrap().revisions[0] = "other".into();
assert!(!state.review_anchor_current(&before));
assert!(state.review_anchor_range(&before).is_none());
}
#[test]