fix: shape_until_scroll if a buffer_line is modified

This commit is contained in:
Hojjat 2026-03-31 10:12:25 -06:00 committed by Ashley Wulber
parent 5651c2d967
commit 1abcf67e17
3 changed files with 14 additions and 0 deletions

View file

@ -426,6 +426,11 @@ impl Buffer {
fn resolve_dirty(&mut self) -> bool {
let dirty = self.dirty;
if dirty.is_empty() {
// individual lines may have been externally invalidated
if self.lines.iter().any(|line| line.needs_reshaping()) {
self.redraw = true;
return true;
}
return false;
}

View file

@ -236,6 +236,10 @@ impl BufferLine {
self.shape_opt.get()
}
pub const fn needs_reshaping(&self) -> bool {
self.shape_opt.is_invalidated() || self.layout_opt.is_invalidated()
}
/// Layout line, will cache results
#[allow(clippy::missing_panics_doc)]
pub fn layout(

View file

@ -42,6 +42,11 @@ impl<T: Clone + Debug> Cached<T> {
}
}
/// Checks if the value was previously cached but has been invalidated.
pub const fn is_invalidated(&self) -> bool {
matches!(self, Self::Unused(_))
}
/// Takes the buffered value if in state `Self::Unused`.
pub fn take_unused(&mut self) -> Option<T> {
if matches!(*self, Self::Unused(_)) {