diff options
| author | Michael Hackner <mhackner@gmail.com> | 2026-08-02 18:08:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-03 04:08:47 +0300 |
| commit | eacea2daf0b72973173b728936b27478374f2cd2 (patch) | |
| tree | 4adff75de53a369b453db25d9c134734a34856b5 /src/app/input | |
| parent | 5eab32da81b403c2a277222ab97417a8bf90c35f (diff) | |
fix: page keys scroll pane scrollback at zsh and REPL prompts (#2191)
* fix: page keys scroll pane scrollback at zsh and REPL prompts
PageUp/PageDown were forwarded to the pane whenever DECCKM (application
cursor) was on, assuming only primary-screen pagers enable it, but zsh's
line editor also enables DECCKM, as do REPLs such as python3. The result
was PageUp scrolling shell history instead of Herdr scrollback.
Bracketed paste discriminates the two: it means the app accepts typed or
pasted text at a prompt, so line editors enable it and pagers do not.
* test: update page key state fixture
---------
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/input')
| -rw-r--r-- | src/app/input/terminal.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/app/input/terminal.rs b/src/app/input/terminal.rs index 36d60e41..1ba2789c 100644 --- a/src/app/input/terminal.rs +++ b/src/app/input/terminal.rs @@ -1971,4 +1971,42 @@ mod tests { .expect("scroll metrics after PageUp"); assert_eq!(end_metrics.offset_from_bottom, 0); } + + #[tokio::test] + async fn page_up_scrolls_shell_like_decckm_with_bracketed_paste() { + let mut app = app_for_mouse_test(); + let mut ws = Workspace::test_new("test"); + let pane_id = ws.tabs[0].root_pane; + let pane_infos = ws.tabs[0].layout.panes(Rect::new(26, 2, 80, 18)); + let info = pane_infos[0].clone(); + // zsh enables DECCKM via smkx and bracketed paste together; bash/fish do not. + let mut bytes = b"\x1b[?1h\x1b[?2004h".to_vec(); + bytes.extend_from_slice(&numbered_lines_bytes(64)); + let (runtime, mut input_rx) = + crate::terminal::TerminalRuntime::test_with_channel_and_scrollback_bytes( + info.inner_rect.width, + info.inner_rect.height, + 16 * 1024, + &bytes, + 4, + ); + ws.tabs[0].runtimes.insert(pane_id, runtime); + + app.state.workspaces = vec![ws]; + app.state.active = Some(0); + app.state.selected = 0; + app.state.mode = Mode::Terminal; + app.state.view.pane_infos = pane_infos; + + app.handle_terminal_key_headless(TerminalKey::new(KeyCode::PageUp, KeyModifiers::empty())); + + assert!( + input_rx.try_recv().is_err(), + "PageUp should not reach the shell" + ); + assert_eq!( + pane_scroll_offset(&app, pane_id), + info.inner_rect.height as usize + ); + } } |
