diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 6076bd6938..e337dc7bbf 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -702,7 +702,7 @@ impl Snapshot { prev_tab_row = tab_point.row(); soft_wrapped = false; } - expected_buffer_rows.push((buffer_row, soft_wrapped)); + expected_buffer_rows.push(if soft_wrapped { None } else { Some(buffer_row) }); } for start_display_row in 0..expected_buffer_rows.len() { @@ -782,7 +782,7 @@ impl<'a> Iterator for Chunks<'a> { } impl<'a> Iterator for BufferRows<'a> { - type Item = (u32, bool); + type Item = Option; fn next(&mut self) -> Option { if self.output_row > self.max_output_row { @@ -802,7 +802,7 @@ impl<'a> Iterator for BufferRows<'a> { self.soft_wrapped = true; } - Some((buffer_row, soft_wrapped)) + Some(if soft_wrapped { None } else { Some(buffer_row) }) } } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 1e0e512ffd..9663968408 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -411,7 +411,7 @@ impl EditorElement { let style = &self.settings.style; let mut layouts = Vec::with_capacity(rows.len()); let mut line_number = String::new(); - for (ix, (buffer_row, soft_wrapped)) in snapshot + for (ix, buffer_row) in snapshot .buffer_rows(rows.start) .take((rows.end - rows.start) as usize) .enumerate() @@ -422,9 +422,7 @@ impl EditorElement { } else { style.line_number }; - if soft_wrapped { - layouts.push(None); - } else { + if let Some(buffer_row) = buffer_row { line_number.clear(); write!(&mut line_number, "{}", buffer_row + 1).unwrap(); layouts.push(Some(cx.text_layout_cache.layout_str( @@ -439,6 +437,8 @@ impl EditorElement { }, )], ))); + } else { + layouts.push(None); } }