Color staged and unstaged hunks differently by opacity (#25108)

Release Notes:

- Make staged diff hunks appear as more opaque than unstaged hunks

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
This commit is contained in:
Cole Miller 2025-02-19 13:33:21 -05:00 committed by GitHub
parent c9bd44f983
commit 8e17b34eff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 265 additions and 175 deletions

View file

@ -9,6 +9,7 @@ pub use position::{TypedOffset, TypedPoint, TypedRow};
use anyhow::{anyhow, Result};
use buffer_diff::{
BufferDiff, BufferDiffEvent, BufferDiffSnapshot, DiffHunkSecondaryStatus, DiffHunkStatus,
DiffHunkStatusKind,
};
use clock::ReplicaId;
use collections::{BTreeMap, Bound, HashMap, HashSet};
@ -135,12 +136,16 @@ pub struct MultiBufferDiffHunk {
impl MultiBufferDiffHunk {
pub fn status(&self) -> DiffHunkStatus {
if self.buffer_range.start == self.buffer_range.end {
DiffHunkStatus::Removed(self.secondary_status)
let kind = if self.buffer_range.start == self.buffer_range.end {
DiffHunkStatusKind::Deleted
} else if self.diff_base_byte_range.is_empty() {
DiffHunkStatus::Added(self.secondary_status)
DiffHunkStatusKind::Added
} else {
DiffHunkStatus::Modified(self.secondary_status)
DiffHunkStatusKind::Modified
};
DiffHunkStatus {
kind,
secondary: self.secondary_status,
}
}
}
@ -6210,7 +6215,7 @@ where
excerpt,
has_trailing_newline: *has_trailing_newline,
is_main_buffer: false,
diff_hunk_status: Some(DiffHunkStatus::Removed(
diff_hunk_status: Some(DiffHunkStatus::deleted(
hunk_info.hunk_secondary_status,
)),
buffer_range: buffer_start..buffer_end,
@ -6256,7 +6261,7 @@ where
has_trailing_newline,
is_main_buffer: true,
diff_hunk_status: inserted_hunk_info
.map(|info| DiffHunkStatus::Added(info.hunk_secondary_status)),
.map(|info| DiffHunkStatus::added(info.hunk_secondary_status)),
buffer_range: buffer_start..buffer_end,
range: start..end,
})