Fix regression causing scrollback-push to not clear text below cursor

If a child program crashes with some text rendered below the cursor,
we fail to clear that text. For example run vim, "pkill -9 vim" and
observe that scrollback-push fails to clean up the leftover text.
Fix that.
This commit is contained in:
Johannes Altmanninger 2025-01-19 13:28:12 +01:00
parent a328fd995b
commit 7ad47c34e8
4 changed files with 4 additions and 5 deletions

View File

@ -27,7 +27,7 @@ New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
- :kbd:`ctrl-z` (undo) after executing a command will restore the previous cursor position instead of placing the cursor at the end of the command line. - :kbd:`ctrl-z` (undo) after executing a command will restore the previous cursor position instead of placing the cursor at the end of the command line.
- The OSC 133 prompt marking feature has learned about kitty's ``click_events=1`` flag, which allows moving fish's cursor by clicking. - The OSC 133 prompt marking feature has learned about kitty's ``click_events=1`` flag, which allows moving fish's cursor by clicking.
- :kbd:`ctrl-l` no longer clears the screen but only pushes to the terminal's scrollback all text above the prompt (via a new special input function ``scrollback-push``). - :kbd:`ctrl-l` now pushes all text located above the prompt to the terminal's scrollback, before clearing and redrawing the screen (via a new special input function ``scrollback-push``).
This feature depends on the terminal advertising via XTGETTCAP support for the ``indn`` and ``cuu`` terminfo capabilities, This feature depends on the terminal advertising via XTGETTCAP support for the ``indn`` and ``cuu`` terminfo capabilities,
and on the terminal supporting Synchronized Output (which is used by fish to detect features). and on the terminal supporting Synchronized Output (which is used by fish to detect features).
If any is missing, the binding falls back to ``clear-screen``. If any is missing, the binding falls back to ``clear-screen``.

View File

@ -66,7 +66,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv alt-l __fish_list_current_token bind --preset $argv alt-l __fish_list_current_token
bind --preset $argv alt-o __fish_preview_current_file bind --preset $argv alt-o __fish_preview_current_file
bind --preset $argv alt-w __fish_whatis_current_token bind --preset $argv alt-w __fish_whatis_current_token
bind --preset $argv ctrl-l scrollback-push repaint bind --preset $argv ctrl-l scrollback-push clear-screen
bind --preset $argv ctrl-c clear-commandline bind --preset $argv ctrl-c clear-commandline
bind --preset $argv ctrl-u backward-kill-line bind --preset $argv ctrl-u backward-kill-line
bind --preset $argv ctrl-k kill-line bind --preset $argv ctrl-k kill-line

View File

@ -3742,7 +3742,6 @@ impl<'a> Reader<'a> {
} }
rl::ScrollbackPush => { rl::ScrollbackPush => {
if !SCROLL_FORWARD_SUPPORTED.load() || !CURSOR_UP_SUPPORTED.load() { if !SCROLL_FORWARD_SUPPORTED.load() || !CURSOR_UP_SUPPORTED.load() {
self.clear_screen_and_repaint();
return; return;
} }
match self.cursor_position_wait() { match self.cursor_position_wait() {
@ -3750,7 +3749,7 @@ impl<'a> Reader<'a> {
&mut Outputter::stdoutput().borrow_mut(), &mut Outputter::stdoutput().borrow_mut(),
CursorPositionWait::Blocking(CursorPositionBlockingWait::ScrollbackPush), CursorPositionWait::Blocking(CursorPositionBlockingWait::ScrollbackPush),
), ),
CursorPositionWait::InitialFeatureProbe => self.clear_screen_and_repaint(), CursorPositionWait::InitialFeatureProbe => (),
CursorPositionWait::Blocking(_) => { CursorPositionWait::Blocking(_) => {
// TODO: re-queue it I guess. // TODO: re-queue it I guess.
FLOG!( FLOG!(

View File

@ -2,7 +2,7 @@
#REQUIRES: command -v tmux #REQUIRES: command -v tmux
isolated-tmux-start isolated-tmux-start
isolated-tmux send-keys 'bind ctrl-g "commandline -f scrollback-push scrollback-push"' Enter C-g isolated-tmux send-keys 'bind ctrl-g "commandline -f scrollback-push scrollback-push clear-screen"' Enter C-g
tmux-sleep tmux-sleep
isolated-tmux capture-pane -p isolated-tmux capture-pane -p
# CHECK: prompt 1> # CHECK: prompt 1>