editor: Fix rare panic in wrap map (#39379)
Closes ZED-1SV Closes ZED-TG Closes ZED-22G Closes ZED-22J This seems to fix the reported error there, but ultimately, this might benefit from a test to reproduce. Hence, marking as draft for now. Release Notes: - Fixed a rare panic whilst wrapping lines.
This commit is contained in:
@@ -19,7 +19,7 @@ use std::{
|
||||
cell::RefCell,
|
||||
cmp::{self, Ordering},
|
||||
fmt::Debug,
|
||||
ops::{Deref, DerefMut, Range, RangeBounds, RangeInclusive},
|
||||
ops::{Deref, DerefMut, Not, Range, RangeBounds, RangeInclusive},
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering::SeqCst},
|
||||
@@ -1879,18 +1879,14 @@ impl Iterator for BlockRows<'_> {
|
||||
}
|
||||
|
||||
let transform = self.transforms.item()?;
|
||||
if let Some(block) = transform.block.as_ref() {
|
||||
if block.is_replacement() && self.transforms.start().0 == self.output_row {
|
||||
if matches!(block, Block::FoldedBuffer { .. }) {
|
||||
Some(RowInfo::default())
|
||||
} else {
|
||||
Some(self.input_rows.next().unwrap())
|
||||
}
|
||||
} else {
|
||||
Some(RowInfo::default())
|
||||
}
|
||||
if transform.block.as_ref().is_none_or(|block| {
|
||||
block.is_replacement()
|
||||
&& self.transforms.start().0 == self.output_row
|
||||
&& matches!(block, Block::FoldedBuffer { .. }).not()
|
||||
}) {
|
||||
self.input_rows.next()
|
||||
} else {
|
||||
Some(self.input_rows.next().unwrap())
|
||||
Some(RowInfo::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ impl<'a> Iterator for WrapChunks<'a> {
|
||||
}
|
||||
|
||||
if self.input_chunk.text.is_empty() {
|
||||
self.input_chunk = self.input_chunks.next().unwrap();
|
||||
self.input_chunk = self.input_chunks.next()?;
|
||||
}
|
||||
|
||||
let mut input_len = 0;
|
||||
|
||||
Reference in New Issue
Block a user