aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-09-15 15:44:36 +0200
committerGitHub <noreply@github.com>2021-09-15 15:44:36 +0200
commit720a3ecbafbb6a0a66025ba560c63ccf3c9a40f1 (patch)
treed6b29e654b5fd799c103d2e3fc6a118f00c9fcdb
parentfix(keys): bring back ctrl-n to get from scroll mode to resize mode (diff)
downloadsl0ppij-720a3ecbafbb6a0a66025ba560c63ccf3c9a40f1.tar.gz
sl0ppij-720a3ecbafbb6a0a66025ba560c63ccf3c9a40f1.tar.xz
sl0ppij-720a3ecbafbb6a0a66025ba560c63ccf3c9a40f1.zip
Fix prompt line overflowing when resizing panes (#725)
* fix(wrap): do not wrap empty lines and properly place cursor when resizing * fix(wrap): truncate last blank line wraps * fix(wrap): truncate lines right after unwrapping them * refactor(grid): remove unused method * docs(changelog): document change
-rw-r--r--CHANGELOG.md1
-rw-r--r--zellij-server/src/panes/grid.rs21
-rw-r--r--zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__clear_scroll_region.snap2
-rw-r--r--zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__emacs_longbuf.snap4
4 files changed, 24 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1eec2618..17b4b9ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* Improve handling of empty valid `yaml` files (https://github.com/zellij-org/zellij/pull/716)
* Add options subcommand to attach (https://github.com/zellij-org/zellij/pull/718)
* Fix: do not pad empty pane frame title (https://github.com/zellij-org/zellij/pull/724)
+* Fix: Do not overflow empty lines when resizing panes (https://github.com/zellij-org/zellij/pull/725)
## [0.16.0] - 2021-08-31
diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs
index 5e3479ee..2d2354c6 100644
--- a/zellij-server/src/panes/grid.rs
+++ b/zellij-server/src/panes/grid.rs
@@ -527,8 +527,8 @@ impl Grid {
for (i, line) in self.viewport.iter().enumerate() {
if line.is_canonical {
canonical_lines_traversed += 1;
+ y_coordinates = i;
if canonical_lines_traversed == canonical_line_index + 1 {
- y_coordinates = i;
break;
}
}
@@ -628,6 +628,23 @@ impl Grid {
}
}
}
+
+ // trim lines after the last empty space that has no following character, because
+ // terminals don't trim empty lines
+ for line in viewport_canonical_lines.iter_mut() {
+ let mut trim_at = None;
+ for (index, character) in line.columns.iter().enumerate() {
+ if character.character != EMPTY_TERMINAL_CHARACTER.character {
+ trim_at = None;
+ } else if trim_at.is_none() {
+ trim_at = Some(index);
+ }
+ }
+ if let Some(trim_at) = trim_at {
+ line.columns.truncate(trim_at);
+ }
+ }
+
let mut new_viewport_rows = vec![];
for mut canonical_line in viewport_canonical_lines {
let mut canonical_line_parts: Vec<Row> = vec![];
@@ -658,9 +675,11 @@ impl Grid {
}
new_viewport_rows.append(&mut canonical_line_parts);
}
+
self.viewport = new_viewport_rows;
let mut new_cursor_y = self.canonical_line_y_coordinates(cursor_canonical_line_index);
+
let new_cursor_x = (cursor_index_in_canonical_line / new_columns)
+ (cursor_index_in_canonical_line % new_columns);
let current_viewport_row_count = self.viewport.len();
diff --git a/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__clear_scroll_region.snap b/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__clear_scroll_region.snap
index b53826df..e5c302a0 100644
--- a/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__clear_scroll_region.snap
+++ b/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__clear_scroll_region.snap
@@ -3,7 +3,7 @@ source: zellij-server/src/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"
---
-00 (C): Welcome to fish, the friendly interactive shell
+00 (C): Welcome to fish, the friendly interactive shell
01 (C): ⋊> ~/c/mosaic on main ⨯ vim some-file 15:07:22
02 (C): ⋊> ~/c/mosaic on main ⨯ 15:07:29
diff --git a/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__emacs_longbuf.snap b/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__emacs_longbuf.snap
index 5c08c323..71cc9bc8 100644
--- a/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__emacs_longbuf.snap
+++ b/zellij-server/src/panes/unit/snapshots/zellij_server__panes__grid__grid_tests__emacs_longbuf.snap
@@ -3,8 +3,8 @@ source: zellij-server/src/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"
---
-00 (C): ➜ mosaic git:(mosaic#130) emacs
-01 (C): ➜ mosaic git:(mosaic#130) emacs -nw
+00 (C): ➜ mosaic git:(mosaic#130) emacs
+01 (C): ➜ mosaic git:(mosaic#130) emacs -nw
02 (C): ➜ mosaic git:(mosaic#130) exit
03 (C):