feat: add syntax-aware diff backgrounds and diagonal gap shading
This commit is contained in:
+22
-1
@@ -147,6 +147,7 @@ pub struct DiffState {
|
||||
pub loading: bool,
|
||||
pub error: Option<String>,
|
||||
pub comparison: Option<Comparison>,
|
||||
pub comparison_id: Option<u64>,
|
||||
pub files: Option<FilePicker>,
|
||||
pub files_visible: bool,
|
||||
pub file: usize,
|
||||
@@ -177,6 +178,7 @@ impl DiffState {
|
||||
loading: true,
|
||||
error: None,
|
||||
comparison: None,
|
||||
comparison_id: None,
|
||||
files: None,
|
||||
files_visible: true,
|
||||
file: 0,
|
||||
@@ -215,7 +217,7 @@ impl DiffState {
|
||||
self.error = None;
|
||||
}
|
||||
|
||||
pub(crate) fn apply_result(&mut self, result: Result<Outcome, String>) {
|
||||
pub(crate) fn apply_result(&mut self, id: u64, result: Result<Outcome, String>) {
|
||||
let expected = self.request_kind.take();
|
||||
self.loading = false;
|
||||
self.pending = None;
|
||||
@@ -254,6 +256,7 @@ impl DiffState {
|
||||
}
|
||||
self.files = Some(files);
|
||||
self.comparison = Some(comparison);
|
||||
self.comparison_id = Some(id);
|
||||
self.phase = Phase::View;
|
||||
self.focus = Focus::Files;
|
||||
self.file = 0;
|
||||
@@ -1236,6 +1239,24 @@ mod tests {
|
||||
assert_eq!(editor.diff().unwrap().file, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn comparison_identity_comes_from_accepted_requests_not_working_labels() {
|
||||
let mut editor = editor();
|
||||
open(&mut editor);
|
||||
let first = choose_pair(&mut editor);
|
||||
assert!(editor.apply_diff_result(first, Ok(Outcome::Comparison(comparison()))));
|
||||
assert_eq!(editor.diff().unwrap().comparison_id, Some(first));
|
||||
editor.handle(Input::Escape);
|
||||
open(&mut editor);
|
||||
assert_eq!(editor.diff().unwrap().comparison_id, None);
|
||||
let second = choose_pair(&mut editor);
|
||||
assert!(second > first);
|
||||
assert!(!editor.apply_diff_result(first, Ok(Outcome::Comparison(comparison()))));
|
||||
assert_eq!(editor.diff().unwrap().comparison_id, None);
|
||||
assert!(editor.apply_diff_result(second, Ok(Outcome::Comparison(comparison()))));
|
||||
assert_eq!(editor.diff().unwrap().comparison_id, Some(second));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn discovery_and_fetch_errors_are_retryable_and_stale_responses_cannot_reopen() {
|
||||
let mut editor = editor();
|
||||
|
||||
Reference in New Issue
Block a user