From 13763fa318b3cf6bed301da6a7918734d0e79a39 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 30 Dec 2024 13:59:03 +0100 Subject: [PATCH] Fix assertion error in when scrollback-push is enqueued from script As soon as we start processing a scrollback-push readline command, we pause execution of all other readline commands until scrollback-push retires. This means that we never get into a situation with two active scrollback-push commands -- unless we are executing readline commands via a script running "commandline -f": since the first part of scrollback-push handling returns immediately, the script will proceed before scrollback-push retires. A second scrollback-push fails an assertion. Work around that for now. In future, scrollback-push should block when invoked by such a script, just like it does when invoked from bindings. --- src/reader.rs | 4 ++++ tests/checks/tmux-scrollback.fish | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/checks/tmux-scrollback.fish diff --git a/src/reader.rs b/src/reader.rs index 55728c7c8..a1c77915f 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -3508,6 +3508,10 @@ impl<'a> Reader<'a> { self.parser.libdata_mut().is_repaint = false; } rl::ScrollbackPush => { + if self.waiting_for_cursor_position.is_some() { + // TODO: re-queue it I guess. + return; + } self.request_cursor_position(WaitingForCursorPosition::ScrollbackPush); } rl::SelfInsert | rl::SelfInsertNotFirst | rl::FuncAnd | rl::FuncOr => { diff --git a/tests/checks/tmux-scrollback.fish b/tests/checks/tmux-scrollback.fish new file mode 100644 index 000000000..28bb350e1 --- /dev/null +++ b/tests/checks/tmux-scrollback.fish @@ -0,0 +1,8 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux + +isolated-tmux-start +isolated-tmux send-keys 'bind ctrl-g "commandline -f scrollback-push scrollback-push"' Enter C-g +tmux-sleep +isolated-tmux capture-pane -p +# CHECK: prompt 1>