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
This commit is contained in:
parent
b1f17a624c
commit
720a3ecbaf
4 changed files with 24 additions and 4 deletions
|
|
@ -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)
|
* 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)
|
* 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 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
|
## [0.16.0] - 2021-08-31
|
||||||
|
|
|
||||||
|
|
@ -527,8 +527,8 @@ impl Grid {
|
||||||
for (i, line) in self.viewport.iter().enumerate() {
|
for (i, line) in self.viewport.iter().enumerate() {
|
||||||
if line.is_canonical {
|
if line.is_canonical {
|
||||||
canonical_lines_traversed += 1;
|
canonical_lines_traversed += 1;
|
||||||
|
y_coordinates = i;
|
||||||
if canonical_lines_traversed == canonical_line_index + 1 {
|
if canonical_lines_traversed == canonical_line_index + 1 {
|
||||||
y_coordinates = i;
|
|
||||||
break;
|
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![];
|
let mut new_viewport_rows = vec![];
|
||||||
for mut canonical_line in viewport_canonical_lines {
|
for mut canonical_line in viewport_canonical_lines {
|
||||||
let mut canonical_line_parts: Vec<Row> = vec![];
|
let mut canonical_line_parts: Vec<Row> = vec![];
|
||||||
|
|
@ -658,9 +675,11 @@ impl Grid {
|
||||||
}
|
}
|
||||||
new_viewport_rows.append(&mut canonical_line_parts);
|
new_viewport_rows.append(&mut canonical_line_parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.viewport = new_viewport_rows;
|
self.viewport = new_viewport_rows;
|
||||||
|
|
||||||
let mut new_cursor_y = self.canonical_line_y_coordinates(cursor_canonical_line_index);
|
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)
|
let new_cursor_x = (cursor_index_in_canonical_line / new_columns)
|
||||||
+ (cursor_index_in_canonical_line % new_columns);
|
+ (cursor_index_in_canonical_line % new_columns);
|
||||||
let current_viewport_row_count = self.viewport.len();
|
let current_viewport_row_count = self.viewport.len();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ source: zellij-server/src/panes/./unit/grid_tests.rs
|
||||||
expression: "format!(\"{:?}\", grid)"
|
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
|
01 (C): ⋊> ~/c/mosaic on main ⨯ vim some-file 15:07:22
|
||||||
02 (C): ⋊> ~/c/mosaic on main ⨯ 15:07:29
|
02 (C): ⋊> ~/c/mosaic on main ⨯ 15:07:29
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ source: zellij-server/src/panes/./unit/grid_tests.rs
|
||||||
expression: "format!(\"{:?}\", grid)"
|
expression: "format!(\"{:?}\", grid)"
|
||||||
|
|
||||||
---
|
---
|
||||||
00 (C): ➜ mosaic git:(mosaic#130) emacs
|
00 (C): ➜ mosaic git:(mosaic#130) emacs
|
||||||
01 (C): ➜ mosaic git:(mosaic#130) emacs -nw
|
01 (C): ➜ mosaic git:(mosaic#130) emacs -nw
|
||||||
02 (C): ➜ mosaic git:(mosaic#130) exit
|
02 (C): ➜ mosaic git:(mosaic#130) exit
|
||||||
03 (C):
|
03 (C):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue