mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-24 05:25:18 +00:00
git: Fewer buffer diff snapshots (#48886)
Release Notes: - N/A --------- Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
This commit is contained in:
parent
aa37edaef1
commit
aba74e6ca3
1 changed files with 14 additions and 1 deletions
|
|
@ -3017,7 +3017,20 @@ impl MultiBuffer {
|
|||
if !diffs.is_empty() {
|
||||
let mut diffs_to_add = Vec::new();
|
||||
for (id, diff) in diffs {
|
||||
if diff.is_inverted || buffer_diff.get(id).is_none() {
|
||||
// For inverted diffs, we excerpt the diff base texts in the multibuffer
|
||||
// and use the diff hunk base text ranges to compute diff transforms.
|
||||
// Those base text ranges are usize, so make sure if the base text changed
|
||||
// we also update the diff snapshot so that we don't use stale offsets
|
||||
if buffer_diff.get(id).is_none_or(|existing_diff| {
|
||||
if !existing_diff.is_inverted {
|
||||
return false;
|
||||
}
|
||||
let base_text = diff.diff.read(cx).base_text_buffer().read(cx);
|
||||
base_text.remote_id() != existing_diff.base_text().remote_id()
|
||||
|| base_text
|
||||
.version()
|
||||
.changed_since(existing_diff.base_text().version())
|
||||
}) {
|
||||
if diffs_to_add.capacity() == 0 {
|
||||
// we'd rather overallocate than reallocate as buffer diffs are quite big
|
||||
// meaning re-allocations will be fairly expensive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue