From 91e0dcd8f9de84a9cd0a45b1e776f59ea527881e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 3 Dec 2021 14:13:46 -0500 Subject: fix wrapping while scrolling inside the scroll region too --- src/grid.rs | 9 +++++---- tests/data/fixtures/wrap.in | 1 + tests/data/fixtures/wrap/32.json | 15 +++++++++++++++ tests/data/fixtures/wrap/32.typescript | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/data/fixtures/wrap/32.json create mode 100644 tests/data/fixtures/wrap/32.typescript diff --git a/src/grid.rs b/src/grid.rs index 785b3cb..d568205 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -612,13 +612,14 @@ impl Grid { pub fn col_wrap(&mut self, width: u16, wrap: bool) { if self.pos.col > self.size.cols - width { - let prev_pos = self.pos; + let mut prev_pos = self.pos; self.pos.col = 0; let scrolled = self.row_inc_scroll(1); + prev_pos.row -= scrolled; let new_pos = self.pos; - self.drawing_row_mut(prev_pos).unwrap().wrap( - wrap && (prev_pos.row + 1 == new_pos.row || scrolled == 1), - ); + self.drawing_row_mut(prev_pos) + .unwrap() + .wrap(wrap && prev_pos.row + 1 == new_pos.row); } } diff --git a/tests/data/fixtures/wrap.in b/tests/data/fixtures/wrap.in index e351293..b04ac81 100644 --- a/tests/data/fixtures/wrap.in +++ b/tests/data/fixtures/wrap.in @@ -29,3 +29,4 @@ a \x1bc\na\x1b[1;79Hデ\n \x1bc\x1b[1;79Hネa\x1b[1;79Hb \x1bc\x1b[1;79Hネa\x1b[1;78Hネ +\x1bc\x1b[24;80Hab diff --git a/tests/data/fixtures/wrap/32.json b/tests/data/fixtures/wrap/32.json new file mode 100644 index 0000000..cdfc959 --- /dev/null +++ b/tests/data/fixtures/wrap/32.json @@ -0,0 +1,15 @@ +{ + "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ab", + "cells": { + "22,79": { + "contents": "a" + }, + "23,0": { + "contents": "b" + } + }, + "cursor_position": [ + 23, + 1 + ] +} \ No newline at end of file diff --git a/tests/data/fixtures/wrap/32.typescript b/tests/data/fixtures/wrap/32.typescript new file mode 100644 index 0000000..c15369f --- /dev/null +++ b/tests/data/fixtures/wrap/32.typescript @@ -0,0 +1 @@ +cab \ No newline at end of file -- cgit v1.2.3-54-g00ecf