Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Fix relative line numbers breaking with nested folds (#47035)
Finn Evers10a536b328e3
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex a59f7105383..ddc33c2de86 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -26994,22 +26994,18 @@ impl EditorSnapshot {let wrap_row = wrap_snapshot.make_wrap_point(first_visible_row, Bias::Left).row();+wrap_row.0 as i64 - base_wrap_row.0 as i64} else {- let folds = if current_selection_head < first_visible_row {- self.folds_in_range(current_selection_head..first_visible_row)- } else {- self.folds_in_range(first_visible_row..current_selection_head)- };-- let folded_lines = folds- .map(|fold| {- let range = fold.range.0.to_point(self);- range.end.row.saturating_sub(range.start.row)- })- .sum::<u32>() as i64;+ let fold_snapshot = self.fold_snapshot();+ let base_fold_row = fold_snapshot+ .to_fold_point(self.to_inlay_point(current_selection_head), Bias::Left)+ .row();+ let fold_row = fold_snapshot+ .to_fold_point(self.to_inlay_point(first_visible_row), Bias::Left)+ .row();- first_visible_row.row as i64 - current_selection_head.row as i64 + folded_lines+ fold_row as i64 - base_fold_row as i64}}