Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Only compute word-diff highlights for visible rows (#58639)
Lukas Wirth86effffd3463
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 29fce5e6ad9..7442284936d 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -4516,6 +4516,11 @@ impl EditorElement {) {let colors = cx.theme().colors();+ let visible_start =+ DisplayPoint::new(start_row, 0).to_offset(&snapshot.display_snapshot, Bias::Left);+ let visible_end = DisplayPoint::new(DisplayRow(start_row.0 + row_infos.len() as u32), 0)+ .to_offset(&snapshot.display_snapshot, Bias::Right);+let word_highlights = display_hunks.into_iter().filter_map(|(hunk, _)| match hunk {@@ -4526,6 +4531,7 @@ impl EditorElement {}).filter(|(_, status)| status.is_modified()).flat_map(|(word_diffs, _)| word_diffs)+ .filter(|word_diff| word_diff.start < visible_end && word_diff.end > visible_start).flat_map(|word_diff| {let display_ranges = snapshot.display_snapshot