mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-26 10:55:12 +03:00
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
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user