1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-02 00:46:42 +03:00

Kill current shell on <c-g> during shell execution

Closes #4907
This commit is contained in:
Maxime Coste 2023-05-29 20:25:56 +10:00
parent cf7c638025
commit 95a4d70379

View File

@ -355,6 +355,7 @@ std::pair<String, int> ShellManager::eval(
client.redraw_ifn();
}, EventMode::Urgent};
bool cancelling = false;
while (not terminated or child_stdin.write_fd() != -1 or
((flags & Flags::WaitForStdout) and
(child_stdout.read_fd() != -1 or child_stderr.read_fd() != -1)))
@ -363,6 +364,11 @@ std::pair<String, int> ShellManager::eval(
{
EventManager::instance().handle_next_events(EventMode::Urgent, &orig_mask);
}
catch (cancel&)
{
kill(pid, SIGINT);
cancelling = true;
}
catch (runtime_error& error)
{
write_to_debug_buffer(format("error while waiting for shell: {}", error.what()));
@ -385,6 +391,9 @@ std::pair<String, int> ShellManager::eval(
(size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count()));
}
if (cancelling)
throw cancel{};
if (previous_status) // restore the status line
{
context.print_status(std::move(*previous_status));