Visitar URL original
Support scrolling overflowing command lines by lemon956 · Pull Request #12939 · fish-shell/fish-shell · GitHub
Skip to content

Support scrolling overflowing command lines - #12939

Open
lemon956 wants to merge 1 commit into
fish-shell:masterfrom
lemon956:fix/commandline-viewport-wheel
Open

lemon956 wants to merge 1 commit into
fish-shell:masterfrom
lemon956:fix/commandline-viewport-wheel

Conversation

@lemon956

Copy link
Copy Markdown

Summary

This implements the command-line viewport approach discussed in #11029 instead of attempting to reconstruct unrendered input from terminal scrollback.

  • measure the complete explicit command line, then materialize only the visible visual-row window
  • capture normal/SGR mouse wheel reporting only while that window is scrollable
  • keep wheel scrolling independent from the editing cursor and repaint unchanged rows incrementally
  • restore prior mouse state and cursor visibility across execution, cancellation, nested readers, child handoff, and SIGHUP cleanup
  • show a rows X to Y of N. Enter executes or continues indicator and document the interaction

Keyboard cursor movement follows the viewport only when it crosses an edge. Enter semantics are unchanged: a complete command executes immediately, while an incomplete command continues editing.

Testing

  • cargo xtask check (245 passed, 8 environment-dependent tests skipped)
  • cargo +1.85.0 clippy --workspace --all-targets -- --deny=warnings
  • cargo xtask format --all --check with Ruff available
  • targeted pexpect/tmux coverage for wheel decoding, soft wrapping, clicks, execution scrollback, nested readers, TTY ownership, and SIGHUP cleanup
  • repeated the main command-line viewport pexpect test 8 times
  • manual testing on Fedora 44 with kitty 0.47.4

TODOs

  • If addressing an issue, a commit message mentions Fixes #<issue-number>
  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

Fixes #11029

Render overflowing command lines through an independent visual-row viewport and capture the mouse wheel only while it is scrollable. Preserve the command buffer and cursor while scrolling, and restore terminal mouse and cursor state across handoffs and exit paths.

Add incremental viewport repainting, a status indicator, documentation, and interactive regressions for soft wraps, execution, nested readers, and SIGHUP cleanup.

Fixes fish-shell#11029
@faho

faho commented Aug 13, 2026

Copy link
Copy Markdown
Member

Unmarked slop

@faho faho closed this Aug 13, 2026
@krobelus krobelus reopened this Sep 1, 2026
Comment thread CHANGELOG.rst

Interactive improvements
------------------------
- Commands that are taller than the terminal can now be browsed with the mouse wheel. The viewport follows keyboard cursor movement only when the cursor crosses an edge, and its status line reminds users what :kbd:`enter` does. Fish captures the wheel only while the command-line viewport is scrollable and returns it to the terminal when the command fits again (:issue:`11029`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is amazing, I think this is exactly the behavior we want.
However I'd clean up a few things before merging this.
For example, this obsoletes the existing implementation of "scrolling" (for example the autoscroll function) so we should remove that code, to minimize a future reader's confusion.
Let me know if you want to do that and you're interested in learning more about the fish code base.

sp.send("\x1b[<64;1;1M")
sp.expect_str("\x1b[?25l")

# A HUP normally means the PTY disappeared, but if it is still writable Fish

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is there a real-world scenario where it doesn't? If not we probably shouldn't add this

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long multi-line commands are truncated without scrollback

3 participants