fix: key review checkmarks by file snapshots instead of revision pairs
This commit is contained in:
+26
-6
@@ -127,6 +127,8 @@ pub struct Hunk {
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct ChangedFile {
|
||||
/// Immutable file-side identities, independent of unrelated revision changes.
|
||||
pub review_revisions: Option<[String; 2]>,
|
||||
pub path: PathBuf,
|
||||
pub old_path: Option<PathBuf>,
|
||||
pub status: FileStatus,
|
||||
@@ -676,6 +678,7 @@ impl DiffState {
|
||||
});
|
||||
comparison.root = root.clone();
|
||||
comparison.files.resize_with(paths.len(), || ChangedFile {
|
||||
review_revisions: None,
|
||||
path: PathBuf::new(),
|
||||
old_path: None,
|
||||
status: FileStatus::Modified,
|
||||
@@ -1801,11 +1804,20 @@ impl DiffState {
|
||||
}
|
||||
let records = &mut self.local_review.document.reviewed_files;
|
||||
records.retain(|record| {
|
||||
record.revisions != comparison.revisions || record.path != file.path
|
||||
record.revisions
|
||||
!= *file
|
||||
.review_revisions
|
||||
.as_ref()
|
||||
.unwrap_or(&comparison.revisions)
|
||||
|| record.path != file.path
|
||||
});
|
||||
if reviewed {
|
||||
records.push(crate::review::ReviewedFile {
|
||||
revisions: comparison.revisions.clone(),
|
||||
revisions: file
|
||||
.review_revisions
|
||||
.as_ref()
|
||||
.unwrap_or(&comparison.revisions)
|
||||
.clone(),
|
||||
path: file.path.clone(),
|
||||
old_path: file.old_path.clone(),
|
||||
after: self
|
||||
@@ -1832,12 +1844,16 @@ impl DiffState {
|
||||
.document
|
||||
.reviewed_files
|
||||
.iter()
|
||||
.filter(|record| record.revisions == comparison.revisions)
|
||||
.map(|record| (&record.path, record))
|
||||
.map(|record| ((&record.revisions, &record.path), record))
|
||||
.collect();
|
||||
for (index, file) in comparison.files.iter().enumerate() {
|
||||
let Some(record) = records
|
||||
.get(&file.path)
|
||||
.get(&(
|
||||
file.review_revisions
|
||||
.as_ref()
|
||||
.unwrap_or(&comparison.revisions),
|
||||
&file.path,
|
||||
))
|
||||
.filter(|record| record.old_path == file.old_path)
|
||||
else {
|
||||
continue;
|
||||
@@ -2263,7 +2279,11 @@ impl DiffState {
|
||||
.reviewed_files
|
||||
.iter()
|
||||
.position(|record| {
|
||||
record.revisions == comparison.revisions
|
||||
record.revisions
|
||||
== *file
|
||||
.review_revisions
|
||||
.as_ref()
|
||||
.unwrap_or(&comparison.revisions)
|
||||
&& record.path == file.path
|
||||
&& record.old_path == file.old_path
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user