sum_tree: Store context on cursor (#34904)

This gets rid of the need to pass context to all cursor functions. In
practice context is always immutable when interacting with cursors.

A nicety of this is in the follow-up PR we will be able to implement
Iterator for all Cursors/filter cursors (hell, we may be able to get rid
of filter cursor altogether, as it is just a custom `filter` impl on
iterator trait).
Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz
2025-07-22 18:20:48 +02:00
committed by GitHub
parent fa3e1ccc37
commit 64d0fec699
23 changed files with 749 additions and 876 deletions
+7 -7
View File
@@ -296,7 +296,7 @@ impl GitBlame {
let row = info
.buffer_row
.filter(|_| info.buffer_id == Some(buffer_id))?;
cursor.seek_forward(&row, Bias::Right, &());
cursor.seek_forward(&row, Bias::Right);
cursor.item()?.blame.clone()
})
}
@@ -389,7 +389,7 @@ impl GitBlame {
}
}
new_entries.append(cursor.slice(&edit.old.start, Bias::Right, &()), &());
new_entries.append(cursor.slice(&edit.old.start, Bias::Right), &());
if edit.new.start > new_entries.summary().rows {
new_entries.push(
@@ -401,7 +401,7 @@ impl GitBlame {
);
}
cursor.seek(&edit.old.end, Bias::Right, &());
cursor.seek(&edit.old.end, Bias::Right);
if !edit.new.is_empty() {
new_entries.push(
GitBlameEntry {
@@ -412,7 +412,7 @@ impl GitBlame {
);
}
let old_end = cursor.end(&());
let old_end = cursor.end();
if row_edits
.peek()
.map_or(true, |next_edit| next_edit.old.start >= old_end)
@@ -421,18 +421,18 @@ impl GitBlame {
if old_end > edit.old.end {
new_entries.push(
GitBlameEntry {
rows: cursor.end(&()) - edit.old.end,
rows: cursor.end() - edit.old.end,
blame: entry.blame.clone(),
},
&(),
);
}
cursor.next(&());
cursor.next();
}
}
}
new_entries.append(cursor.suffix(&()), &());
new_entries.append(cursor.suffix(), &());
drop(cursor);
self.buffer_snapshot = new_snapshot;