diff --git a/src/buffer.rs b/src/buffer.rs index 14684f7..9d8b49a 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -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; } diff --git a/src/buffer_line.rs b/src/buffer_line.rs index 0f3933c..4548604 100644 --- a/src/buffer_line.rs +++ b/src/buffer_line.rs @@ -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( diff --git a/src/cached.rs b/src/cached.rs index 51079e8..6aaa932 100644 --- a/src/cached.rs +++ b/src/cached.rs @@ -42,6 +42,11 @@ impl Cached { } } + /// 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 { if matches!(*self, Self::Unused(_)) {