TextArea: fix cursor after content change

This commit is contained in:
Alexandre Bury 2017-12-07 13:48:41 -08:00
parent 70906aa5de
commit fdf4a0db4b

View File

@ -66,6 +66,7 @@ impl TextArea {
/// Sets the content of the view. /// Sets the content of the view.
pub fn set_content<S: Into<String>>(&mut self, content: S) { pub fn set_content<S: Into<String>>(&mut self, content: S) {
self.content = content.into(); self.content = content.into();
self.cursor = min(self.cursor, self.content.len());
if let Some(size) = self.size_cache.map(|s| s.map(|s| s.value)) { if let Some(size) = self.size_cache.map(|s| s.map(|s| s.value)) {
self.compute_rows(size); self.compute_rows(size);
} }