Fix two issues with diff highlights (#24309)

* fix syntax highlighting of deleted text when buffer language changes
* do not highlight entire untracked files as created, except in the
project diff view

Release Notes:

- N/A

Co-authored-by: ConradIrwin <conrad.irwin@gmail.com>
Co-authored-by: cole-miller <m@cole-miller.net>
This commit is contained in:
Max Brunsfeld 2025-02-05 13:29:39 -08:00 committed by GitHub
parent 9114ca973c
commit ca01a8b9cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 126 additions and 52 deletions

View file

@ -74,6 +74,18 @@ impl BufferDiff {
}
}
pub fn new_with_single_insertion(buffer: &BufferSnapshot) -> Self {
Self {
tree: SumTree::from_item(
InternalDiffHunk {
buffer_range: Anchor::MIN..Anchor::MAX,
diff_base_byte_range: 0..0,
},
buffer,
),
}
}
pub fn build(diff_base: Option<&str>, buffer: &text::BufferSnapshot) -> Self {
let mut tree = SumTree::new(buffer);