Todo:

* [x] Open diffed files as regular buffers
* [x] Update diff when buffers change
* [x] Show diffed filenames in the tab title
* [x] Investigate why syntax highlighting isn't reliably handled for old
text
* [x] remove unstage/restore buttons

Release Notes:

- Adds `zed --diff A B` to show the diff between the two files

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Conrad Irwin 2025-06-18 08:43:23 -06:00 committed by GitHub
parent 2f52e2d285
commit 45b5b2e60d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 655 additions and 35 deletions

View file

@ -4268,6 +4268,11 @@ impl BufferSnapshot {
self.non_text_state_update_count
}
/// An integer version that changes when the buffer's syntax changes.
pub fn syntax_update_count(&self) -> usize {
self.syntax.update_count()
}
/// Returns a snapshot of underlying file.
pub fn file(&self) -> Option<&Arc<dyn File>> {
self.file.as_ref()

View file

@ -32,6 +32,7 @@ pub struct SyntaxSnapshot {
parsed_version: clock::Global,
interpolated_version: clock::Global,
language_registry_version: usize,
update_count: usize,
}
#[derive(Default)]
@ -257,7 +258,9 @@ impl SyntaxMap {
}
pub fn clear(&mut self, text: &BufferSnapshot) {
let update_count = self.snapshot.update_count + 1;
self.snapshot = SyntaxSnapshot::new(text);
self.snapshot.update_count = update_count;
}
}
@ -268,6 +271,7 @@ impl SyntaxSnapshot {
parsed_version: clock::Global::default(),
interpolated_version: clock::Global::default(),
language_registry_version: 0,
update_count: 0,
}
}
@ -275,6 +279,10 @@ impl SyntaxSnapshot {
self.layers.is_empty()
}
pub fn update_count(&self) -> usize {
self.update_count
}
pub fn interpolate(&mut self, text: &BufferSnapshot) {
let edits = text
.anchored_edits_since::<(usize, Point)>(&self.interpolated_version)
@ -443,6 +451,8 @@ impl SyntaxSnapshot {
self.language_registry_version = registry.version();
}
}
self.update_count += 1;
}
fn reparse_with_ranges(