diff --git a/src/pager.rs b/src/pager.rs index ec800b811..0407986e4 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -909,7 +909,7 @@ pub fn render(&self) -> PageRendering { rendering.search_field_line = self.search_field_line.clone(); for cols in (1..=PAGER_MAX_COLS).rev() { // Initially empty rendering. - rendering.screen_data.resize(0); + rendering.screen_data.clear_lines(); // Determine how many rows we would need if we had 'cols' columns. Then determine how many // columns we want from that. For example, say we had 19 completions. We can fit them into 6 diff --git a/src/screen.rs b/src/screen.rs index 3871c8f33..2dcd8b5fa 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -163,6 +163,10 @@ pub fn add_line(&mut self) -> &mut Line { self.line_datas.last_mut().unwrap() } + pub fn clear_lines(&mut self) { + self.line_datas.clear() + } + pub fn resize(&mut self, size: usize) { self.line_datas.resize(size, Default::default()) } @@ -350,7 +354,7 @@ struct ScrolledCursor { // Clear the desired screen and set its width. self.desired.screen_width = Some(screen_width); - self.desired.resize(0); + self.desired.clear_lines(); self.desired.cursor.x = 0; self.desired.cursor.y = 0; @@ -554,7 +558,7 @@ pub fn reset_line(&mut self, repaint_prompt: bool /* = false */) { self.actual_left_prompt = None; self.need_clear_screen = true; } - self.actual.resize(0); + self.actual.clear_lines(); self.need_clear_lines = true; // This should prevent resetting the cursor position during the next repaint. @@ -674,7 +678,7 @@ pub fn offset_in_cmdline_given_cursor( /// The screen width must be provided for the PROMPT_SP hack. pub fn reset_abandoning_line(&mut self, screen_width: usize) { self.actual.cursor.y = 0; - self.actual.resize(0); + self.actual.clear_lines(); self.actual_left_prompt = None; self.need_clear_lines = true;