Skip to content

Commit c6695bd

Browse files
fix(panes): scrollback page/halfpage up/down row count
1 parent 7ef7cd5 commit c6695bd

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

zellij-server/src/tab/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,8 +3223,7 @@ impl Tab {
32233223

32243224
pub fn scroll_active_terminal_up_page(&mut self, client_id: ClientId) {
32253225
if let Some(active_pane) = self.get_active_pane_or_floating_pane_mut(client_id) {
3226-
// prevent overflow when row == 0
3227-
let scroll_rows = active_pane.rows().max(1).saturating_sub(1);
3226+
let scroll_rows = active_pane.get_content_rows();
32283227
active_pane.scroll_up(scroll_rows, client_id);
32293228
}
32303229
}
@@ -3234,8 +3233,7 @@ impl Tab {
32343233
let fictitious_client_id = 1; // this is not checked for terminal panes and we
32353234
// don't have an actual client id here
32363235
// TODO: traits were a mistake
3237-
// prevent overflow when row == 0
3238-
let scroll_rows = terminal_pane.rows().max(1).saturating_sub(1);
3236+
let scroll_rows = terminal_pane.get_content_rows();
32393237
terminal_pane.scroll_up(scroll_rows, fictitious_client_id);
32403238
}
32413239
}
@@ -3274,8 +3272,7 @@ impl Tab {
32743272

32753273
pub fn scroll_active_terminal_up_half_page(&mut self, client_id: ClientId) {
32763274
if let Some(active_pane) = self.get_active_pane_or_floating_pane_mut(client_id) {
3277-
// prevent overflow when row == 0
3278-
let scroll_rows = (active_pane.rows().max(1).saturating_sub(1)) / 2;
3275+
let scroll_rows = active_pane.get_content_rows() / 2;
32793276
active_pane.scroll_up(scroll_rows, client_id);
32803277
}
32813278
}
@@ -3285,7 +3282,7 @@ impl Tab {
32853282
|| format!("failed to scroll down half a page in active pane for client {client_id}");
32863283

32873284
if let Some(active_pane) = self.get_active_pane_or_floating_pane_mut(client_id) {
3288-
let scroll_rows = (active_pane.rows().max(1) - 1) / 2;
3285+
let scroll_rows = active_pane.get_content_rows() / 2;
32893286
active_pane.scroll_down(scroll_rows, client_id);
32903287
if !active_pane.is_scrolled() {
32913288
if let PaneId::Terminal(raw_fd) = active_pane.pid() {
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
22
source: zellij-server/src/./unit/screen_tests.rs
3-
assertion_line: 1593
43
expression: "format!(\"{}\", snapshot)"
54
---
6-
00 (C): ┌ Pane #1 ────────────── SCROLL: 9/13 ┐┌ Pane #2 ─────────────────────────────┐
7-
01 (C): │fill pane up with something 4 ││ │
8-
02 (C): │fill pane up with something 5 ││ │
9-
03 (C): │fill pane up with something 6 ││ │
10-
04 (C): │fill pane up with something 7 ││ │
11-
05 (C): │fill pane up with something 8 ││ │
12-
06 (C): │fill pane up with something 9 ││ │
13-
07 (C): │fill pane up with something 10 ││ │
14-
08 (C): │fill pane up with something 11 ││ │
5+
00 (C): ┌ Pane #1 ────────────── SCROLL: 8/13 ┐┌ Pane #2 ─────────────────────────────┐
6+
01 (C): │fill pane up with something 5 ││ │
7+
02 (C): │fill pane up with something 6 ││ │
8+
03 (C): │fill pane up with something 7 ││ │
9+
04 (C): │fill pane up with something 8 ││ │
10+
05 (C): │fill pane up with something 9 ││ │
11+
06 (C): │fill pane up with something 10 ││ │
12+
07 (C): │fill pane up with something 11 ││ │
13+
08 (C): │fill pane up with something 12 ││ │
1514
09 (C): └──────────────────────────────────────┘└──────────────────────────────────────┘
16-
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
22
source: zellij-server/src/./unit/screen_tests.rs
3-
assertion_line: 1530
43
expression: "format!(\"{}\", snapshot)"
54
---
6-
00 (C): ┌ Pane #1 ────────────── SCROLL: 9/13 ┐┌ Pane #2 ─────────────────────────────┐
7-
01 (C): │fill pane up with something 4 ││ │
8-
02 (C): │fill pane up with something 5 ││ │
9-
03 (C): │fill pane up with something 6 ││ │
10-
04 (C): │fill pane up with something 7 ││ │
11-
05 (C): │fill pane up with something 8 ││ │
12-
06 (C): │fill pane up with something 9 ││ │
13-
07 (C): │fill pane up with something 10 ││ │
14-
08 (C): │fill pane up with something 11 ││ │
5+
00 (C): ┌ Pane #1 ────────────── SCROLL: 8/13 ┐┌ Pane #2 ─────────────────────────────┐
6+
01 (C): │fill pane up with something 5 ││ │
7+
02 (C): │fill pane up with something 6 ││ │
8+
03 (C): │fill pane up with something 7 ││ │
9+
04 (C): │fill pane up with something 8 ││ │
10+
05 (C): │fill pane up with something 9 ││ │
11+
06 (C): │fill pane up with something 10 ││ │
12+
07 (C): │fill pane up with something 11 ││ │
13+
08 (C): │fill pane up with something 12 ││ │
1514
09 (C): └──────────────────────────────────────┘└──────────────────────────────────────┘
16-

0 commit comments

Comments
 (0)