Diff view: Fold excerpts of deleted files by default (#25436)

Release Notes:

- N/A
This commit is contained in:
João Marcos 2025-02-24 12:52:13 -03:00 committed by GitHub
parent 2b28b5969f
commit d1302a7a08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View file

@ -1448,7 +1448,7 @@ impl MultiBuffer {
excerpt.range.context.start,
))
}
/// Sets excerpts, returns `true` if at least one new excerpt was added.
pub fn set_excerpts_for_path(
&mut self,
path: PathKey,
@ -1456,7 +1456,7 @@ impl MultiBuffer {
ranges: Vec<Range<Point>>,
context_line_count: u32,
cx: &mut Context<Self>,
) {
) -> bool {
let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot());
let mut insert_after = self
@ -1475,6 +1475,7 @@ impl MultiBuffer {
let mut new_excerpt_ids = Vec::new();
let mut to_remove = Vec::new();
let mut to_insert = Vec::new();
let mut added_a_new_excerpt = false;
let snapshot = self.snapshot(cx);
let mut excerpts_cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
@ -1489,6 +1490,7 @@ impl MultiBuffer {
continue;
}
(Some(_), None) => {
added_a_new_excerpt = true;
to_insert.push(new_iter.next().unwrap());
continue;
}
@ -1552,6 +1554,8 @@ impl MultiBuffer {
} else {
self.buffers_by_path.insert(path, new_excerpt_ids);
}
added_a_new_excerpt
}
pub fn paths(&self) -> impl Iterator<Item = PathKey> + '_ {