mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 08:58:01 +00:00
Send fish_cancel event on control-C again
This adds support for sending fish_cancel, and a test for it. Fixes #7384.
This commit is contained in:
parent
63cf3e972f
commit
e9902159c2
2 changed files with 27 additions and 0 deletions
|
@ -2773,6 +2773,10 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||
|
||||
set_command_line_and_position(&command_line, L"", 0);
|
||||
s_reset_abandoning_line(&screen, termsize_last().width - command_line.size());
|
||||
|
||||
// Post fish_cancel, allowing it to fire.
|
||||
signal_clear_cancel();
|
||||
event_fire_generic(parser(), L"fish_cancel");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
23
tests/pexpects/cancel_event.py
Normal file
23
tests/pexpects/cancel_event.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
from pexpect_helper import SpawnedProc
|
||||
import signal
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_str, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_str, sp.expect_prompt
|
||||
expect_prompt()
|
||||
|
||||
# Verify that cancel-commandline does what we expect - see #7384.
|
||||
send("not executed")
|
||||
sleep(0.05)
|
||||
os.kill(sp.spawn.pid, signal.SIGINT)
|
||||
sp.expect_str("not executed^C")
|
||||
expect_prompt(increment=False)
|
||||
|
||||
sendline("function cancelhandler --on-event fish_cancel ; echo yay cancelled ; end")
|
||||
expect_prompt()
|
||||
send("still not executed")
|
||||
sleep(0.05)
|
||||
os.kill(sp.spawn.pid, signal.SIGINT)
|
||||
expect_str("still not executed^C")
|
||||
expect_prompt("yay cancelled", increment=False)
|
Loading…
Reference in a new issue