Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

editor: Use tabs bitmask when syncing (#48366)

Marco Mihai Condrache0056bbe38687
diff --git a/crates/editor/src/display_map/tab_map.rs b/crates/editor/src/display_map/tab_map.rs
index 4e768a47715..11db0a4f121 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;