From 455a2a817cf59b5ca707ea024db27738f55024d2 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sat, 9 Jul 2016 18:26:52 -0700 Subject: [PATCH] Invalidate TextView cache on content change --- src/view/text_view.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/view/text_view.rs b/src/view/text_view.rs index 66681ec..033469a 100644 --- a/src/view/text_view.rs +++ b/src/view/text_view.rs @@ -96,6 +96,7 @@ impl TextView { pub fn set_content(&mut self, content: &str) { let content = strip_last_newline(content); self.content = content.to_string(); + self.invalidate(); } /// Returns the current text in this view. @@ -153,6 +154,11 @@ impl TextView { self.last_size = Some(size); } } + + // Invalidates the cache, so next call will recompute everything. + fn invalidate(&mut self) { + self.last_size = None; + } } // Given a multiline string, and a given maximum width,