sum_tree: Do not implement Dimension on tuples, use new Dimensions wrapper instead (#35482)

This is a bit of a readability improvement IMHO; I often find myself
confused when dealing when dimension pairs, as there's no easy way to
jump to the implementation of a dimension for tuples to remind myself
for the n-th time how exactly that impl works. Now it should be possible
to jump directly to that impl.

Another bonus is that Dimension supports 3-ary tuples as well - by using
a () as a default value of a 3rd dimension.


Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-05 02:37:22 +02:00 committed by GitHub
parent be2f54b233
commit 07e3d53d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 215 additions and 141 deletions

View file

@ -96,6 +96,7 @@ use std::{
sync::Arc,
time::{Duration, Instant},
};
use sum_tree::Dimensions;
use text::{Anchor, BufferId, LineEnding, OffsetRangeExt};
use url::Url;
use util::{
@ -7253,7 +7254,9 @@ impl LspStore {
let build_incremental_change = || {
buffer
.edits_since::<(PointUtf16, usize)>(previous_snapshot.snapshot.version())
.edits_since::<Dimensions<PointUtf16, usize>>(
previous_snapshot.snapshot.version(),
)
.map(|edit| {
let edit_start = edit.new.start.0;
let edit_end = edit_start + (edit.old.end.0 - edit.old.start.0);