mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-28 01:11:15 -03:00
Fix crash when history pager is closed before search
With
bind ctrl-r 'sleep 1' history-pager
typing ctrl-r,escape crashes fish in the history pager completion callback,
because the history pager has already been closed.
Prior to 55fd43d86c (Port reader, 2023-12-22), the completion callback
would not crash open a pager -- which causes weird races with the
user input.
Apparently this crash as been triggered by running "playwright",
and -- while that's running typing ctrl-r ligh escape.
Those key strokes were received while the kitty keyboard protocol
was active, possibly a race.
Fixes #11355
This commit is contained in:
@@ -5271,7 +5271,9 @@ fn fill_history_pager(
|
||||
return; // Stale request.
|
||||
}
|
||||
let history_size = zelf.history.size();
|
||||
let history_pager = zelf.history_pager.as_mut().unwrap();
|
||||
let Some(history_pager) = zelf.history_pager.as_mut() else {
|
||||
return; // Pager has been closed.
|
||||
};
|
||||
assert!(result.range.start < result.range.end);
|
||||
*history_pager = result.range;
|
||||
zelf.pager.extra_progress_text =
|
||||
|
||||
@@ -353,7 +353,7 @@ send("\x1b")
|
||||
expect_str("foo")
|
||||
send("\x1b[A")
|
||||
expect_str("bind escape 'echo foo'")
|
||||
sendline("")
|
||||
sendline("bind --erase escape")
|
||||
expect_prompt()
|
||||
|
||||
send(" a b c d\x01") # ctrl-a, move back to the beginning of the line
|
||||
@@ -405,6 +405,11 @@ expect_prompt()
|
||||
sendline("commandline -f and")
|
||||
expect_prompt()
|
||||
|
||||
sendline("bind ctrl-g 'sleep 1' history-pager")
|
||||
expect_prompt()
|
||||
send("\x07") # ctrl-g
|
||||
send("\x1b[27u") # escape, to close pager
|
||||
|
||||
# Check that the builtin version of `exit` works
|
||||
# (for obvious reasons this MUST BE LAST)
|
||||
sendline("function myexit; echo exit; exit; end; bind ctrl-z myexit")
|
||||
|
||||
Reference in New Issue
Block a user