From 0056bbe38687937487030cb5198cd72df1e12205 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Wed, 4 Feb 2026 23:21:57 +0100 Subject: [PATCH] editor: Use tabs bitmask when syncing (#48366) Release Notes: - N/A --- crates/editor/src/display_map/tab_map.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/display_map/tab_map.rs b/crates/editor/src/display_map/tab_map.rs index 4e768a477159820ea380aa48a123d103c0c2f6a2..11db0a4f12105c607a30e98e69157c6c2c2b32f0 100644 --- a/crates/editor/src/display_map/tab_map.rs +++ b/crates/editor/src/display_map/tab_map.rs @@ -77,9 +77,10 @@ impl TabMap { false, Highlights::default(), ) { - // todo(performance use tabs bitmask) - for (ix, _) in chunk.text.match_indices('\t') { - let offset_from_edit = offset_from_edit + (ix as u32); + let mut remaining_tabs = chunk.tabs; + while remaining_tabs != 0 { + let ix = remaining_tabs.trailing_zeros(); + let offset_from_edit = offset_from_edit + ix; if first_tab_offset.is_none() { first_tab_offset = Some(offset_from_edit); } @@ -93,6 +94,8 @@ impl TabMap { } else if !was_expanded && !is_expanded { break 'outer; } + + remaining_tabs &= remaining_tabs - 1; } offset_from_edit += chunk.text.len() as u32;