Skip to content

Commit 8f6a7bd

Browse files
author
Stephan Dilly
committed
fix rare showing of wrong diff
1 parent c72678d commit 8f6a7bd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

asyncgit/src/diff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
};
1111

1212
///
13-
#[derive(Default, Hash, Clone)]
13+
#[derive(Default, Hash, Clone, PartialEq)]
1414
pub struct DiffParams(pub String, pub bool);
1515

1616
struct Request<R, A>(R, Option<A>);
@@ -42,10 +42,10 @@ impl AsyncDiff {
4242
}
4343

4444
///
45-
pub fn last(&mut self) -> Option<FileDiff> {
45+
pub fn last(&mut self) -> Option<(DiffParams, FileDiff)> {
4646
let last = self.last.lock().unwrap();
4747
if let Some(res) = last.clone() {
48-
Some(res.result)
48+
Some((res.params, res.result))
4949
} else {
5050
None
5151
}

src/app.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,10 @@ impl App {
281281
if self.diff.current() == (path.clone(), is_stage) {
282282
// we are already showing a diff of the right file
283283
// maybe the diff changed (outside file change)
284-
if let Some(last) = self.git_diff.last() {
285-
self.diff.update(path, is_stage, last);
284+
if let Some((params, last)) = self.git_diff.last() {
285+
if params == diff_params {
286+
self.diff.update(path, is_stage, last);
287+
}
286288
}
287289
} else {
288290
// we dont show the right diff right now, so we need to request

0 commit comments

Comments
 (0)