Fix *Map randomized tests (#64527)

Closes https://github.com/zed-industries/zed/issues/64444

Ensures that with `ITERATIONS=200000 OPERATIONS=30`, each of the
following tests pass: `test_random_inlays`, `test_random_folds`,
`test_random_tabs`, `test_random_wraps`, `test_random_display_map`,
`test_random_blocks`, and 12/14 shards of the diff test.

Each comment contains the bug and the fix explanation.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov
2026-09-23 16:13:31 +00:00
committed by GitHub
parent 9183ba4c55
commit eb2f43d982
6 changed files with 156 additions and 37 deletions
+10 -1
View File
@@ -1408,6 +1408,10 @@ fn compare_hunks(
let mut last_unchanged_new_hunk_end: Option<text::Anchor> = None;
let mut has_changes = false;
let mut extended_end_candidate: Option<text::Anchor> = None;
let base_text_changed = old_base_text.remote_id() != new_base_text.remote_id()
|| new_base_text
.version()
.changed_since(old_base_text.version());
loop {
match (new_cursor.item(), old_cursor.item()) {
@@ -1437,7 +1441,12 @@ fn compare_hunks(
new_cursor.next();
}
Ordering::Equal => {
if new_hunk != old_hunk {
let base_text_differs = base_text_changed
&& !old_base_text
.chars_for_range(old_hunk.diff_base_byte_range.clone())
.eq(new_base_text
.chars_for_range(new_hunk.diff_base_byte_range.clone()));
if new_hunk != old_hunk || base_text_differs {
has_changes = true;
extended_end_candidate = None;
start.get_or_insert(new_hunk.buffer_range.start);