mirror of
https://github.com/RGBCube/serenity
synced 2025-05-26 01:45:06 +00:00
Shell: Break out of continuation when ^C is pressed
This fixes the little issue with Shell not allowing cancellation of commands once they were in continuation mode ``` $ ls ' $ # No matter what we do here, we cannot escape 'ls' ```
This commit is contained in:
parent
98d25324fd
commit
6cd4d136a0
1 changed files with 17 additions and 0 deletions
|
@ -1540,8 +1540,25 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
StringBuilder complete_line_builder;
|
StringBuilder complete_line_builder;
|
||||||
|
|
||||||
|
bool should_break_current_command { false };
|
||||||
|
|
||||||
|
editor.on_interrupt_handled = [&] {
|
||||||
|
if (s_should_continue != ExitCodeOrContinuationRequest::ContinuationRequest::Nothing) {
|
||||||
|
should_break_current_command = true;
|
||||||
|
editor.finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto line = editor.get_line(prompt());
|
auto line = editor.get_line(prompt());
|
||||||
|
|
||||||
|
if (should_break_current_command) {
|
||||||
|
complete_line_builder.clear();
|
||||||
|
s_should_continue = ExitCodeOrContinuationRequest::ContinuationRequest::Nothing;
|
||||||
|
should_break_current_command = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.is_empty())
|
if (line.is_empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue