From 4380d0864b1098909bdcfec132b866c34924517e Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 20 Oct 2018 22:30:59 +0000 Subject: Fix rotation of selection below 0 Whenever the viewport is scrolled, the selection is rotated to make sure that it moves with the viewport. However this did not correctly handle the underflow that happens when the selection goes below 0. This resolves that problem for the selection by moving the internal line representation to an isize, thus correctly keeping track of the selection start/end points even when they have a negative index. Once the selection is converted to a span, the lines are clamped to the visible region. This fixes #1640 and fixes #1643. --- src/term/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index 495a7567..f4563922 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -973,8 +973,9 @@ impl Term { } } + let alt_screen = self.mode.contains(TermMode::ALT_SCREEN); let selection = self.grid.selection.clone()?; - let span = selection.to_span(self)?; + let span = selection.to_span(self, alt_screen)?; let mut res = String::new(); @@ -1058,8 +1059,9 @@ impl Term { config: &'b Config, window_focused: bool, ) -> RenderableCellsIter { + let alt_screen = self.mode.contains(TermMode::ALT_SCREEN); let selection = self.grid.selection.as_ref() - .and_then(|s| s.to_span(self)) + .and_then(|s| s.to_span(self, alt_screen)) .map(|span| { span.to_locations() }); -- cgit