feat: refresh diffs when selected jj bookmarks move
This commit is contained in:
+20
-5
@@ -23,7 +23,7 @@ use crate::{
|
||||
DocumentEvent, DocumentEventKind, DocumentSnapshot, PluginEvent, PluginUpdate,
|
||||
TextPosition, UpdateEffect,
|
||||
},
|
||||
repository::Repository,
|
||||
repository::{CheckoutRefresh, Repository},
|
||||
ruby::{Config, RubyPlugin, load_config},
|
||||
};
|
||||
|
||||
@@ -321,7 +321,15 @@ impl DiffWorker {
|
||||
buffers,
|
||||
} => repository
|
||||
.refresh_checkout(comparison_id, id, follow_working, &buffers)
|
||||
.map(DiffOutcome::CheckoutRefresh),
|
||||
.map(|refresh| match refresh {
|
||||
Some(CheckoutRefresh::Bookmark(comparison)) => {
|
||||
DiffOutcome::BookmarkRefresh(comparison)
|
||||
}
|
||||
Some(CheckoutRefresh::Checkout(comparison)) => {
|
||||
DiffOutcome::CheckoutRefresh(Some(comparison))
|
||||
}
|
||||
None => DiffOutcome::CheckoutRefresh(None),
|
||||
}),
|
||||
DiffOperation::LoadFile {
|
||||
comparison_id,
|
||||
file_index,
|
||||
@@ -2177,7 +2185,7 @@ mod tests {
|
||||
use crate::diff::{Catalog, Category, Comparison, RepoKind, Revision, RevisionTarget};
|
||||
let fixture = Fixture::new();
|
||||
fixture.file("buffer.txt", "base");
|
||||
for working in [true, false] {
|
||||
for (working, bookmark) in [(true, false), (false, false), (true, true), (false, true)] {
|
||||
let mut session = fixture.open("");
|
||||
session.editor.execute("diff");
|
||||
let (id, _) = session.editor.take_diff_request().unwrap();
|
||||
@@ -2188,7 +2196,14 @@ mod tests {
|
||||
notice: None,
|
||||
entries: [
|
||||
RevisionTarget::Working,
|
||||
RevisionTarget::Commit("base".into()),
|
||||
if bookmark {
|
||||
RevisionTarget::Bookmark {
|
||||
name: "base".into(),
|
||||
remote: None,
|
||||
}
|
||||
} else {
|
||||
RevisionTarget::Commit("base".into())
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.map(|target| Revision {
|
||||
@@ -2224,7 +2239,7 @@ mod tests {
|
||||
assert!(session.editor.take_next_diff_request().is_none());
|
||||
session.refresh_checkout_diffs_at(now + Duration::from_secs(tick));
|
||||
let request = session.editor.take_next_diff_request();
|
||||
assert_eq!(request.is_some(), !working || follow);
|
||||
assert_eq!(request.is_some(), !working || follow || bookmark);
|
||||
if let Some((_, refresh, operation)) = request {
|
||||
assert!(
|
||||
matches!(operation, DiffOperation::RefreshCheckout { comparison_id, follow_working, .. }
|
||||
|
||||
Reference in New Issue
Block a user