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

@ -1001,6 +1001,23 @@ impl Buffer {
}
}
pub fn build_empty_snapshot(cx: &mut App) -> BufferSnapshot {
let entity_id = cx.reserve_entity::<Self>().entity_id();
let buffer_id = entity_id.as_non_zero_u64().into();
let text =
TextBuffer::new_normalized(0, buffer_id, Default::default(), Rope::new()).snapshot();
let syntax = SyntaxMap::new(&text).snapshot();
BufferSnapshot {
text,
syntax,
file: None,
diagnostics: Default::default(),
remote_selections: Default::default(),
language: None,
non_text_state_update_count: 0,
}
}
#[cfg(any(test, feature = "test-support"))]
pub fn build_snapshot_sync(
text: Rope,