From e12f9d9ee4e6b902436d0282e4a1e47ed7d54d6c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 5 Nov 2019 10:59:13 -0500 Subject: stop wrapping if the number of cols changes --- src/grid.rs | 6 ++++++ tests/basic.rs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/grid.rs b/src/grid.rs index 50942f4..d7abbad 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -45,6 +45,12 @@ impl Grid { } pub fn set_size(&mut self, size: Size) { + if size.cols != self.size.cols { + for row in &mut self.rows { + row.wrap(false); + } + } + self.size = size; if self.scroll_bottom >= size.rows { diff --git a/tests/basic.rs b/tests/basic.rs index afb090a..4478218 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -44,6 +44,25 @@ fn set_size() { parser.process(b"\x1b[?1049l"); assert_eq!(parser.screen().size(), (24, 80)); assert_eq!(parser.screen().cursor_position(), (23, 4)); + + parser.screen_mut().set_size(34, 8); + parser.process(b"\x1bc01234567890123456789"); + assert_eq!( + parser.screen().contents(0, 0, 33, 7), + "01234567890123456789" + ); + + parser.screen_mut().set_size(24, 80); + assert_eq!( + parser.screen().contents(0, 0, 23, 79), + "01234567\n89012345\n6789" + ); + + parser.screen_mut().set_size(34, 8); + assert_eq!( + parser.screen().contents(0, 0, 23, 79), + "01234567\n89012345\n6789" + ); } #[test] -- cgit v1.2.3-54-g00ecf