mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Use options to represent soft-wrapped buffer rows
Co-Authored-By: Nathan Sobo <nathan@zed.dev> Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
d9283efbe6
commit
198f6694b7
2 changed files with 7 additions and 7 deletions
|
@ -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<u32>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
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) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue