Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke set_console_echo() on close. #627

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ executor::executor(parser& metadata, std::istream& input, std::ostream& output,
metadata.configured.log.verbose
}
{
// Turn of console echoing from std::cin to std:cout.
system::unset_console_echo();

// Capture <ctrl-c>.
initialize_stop();
}
Expand Down Expand Up @@ -2514,7 +2511,14 @@ void executor::subscribe_capture()
// is running a backup (for example), resulting in a try_lock warning loop.
capture_.subscribe([&](const code& ec, const std::string& line)
{
const auto token = system::trim_copy(line);
// The only case in which false may be returned.
if (ec == network::error::service_stopped)
{
set_console_echo();
return false;
}

const auto token = trim_copy(line);

// <control>-c emits empty token on Win32.
if (token.empty())
Expand Down Expand Up @@ -2550,7 +2554,7 @@ void executor::subscribe_capture()
case menu::close:
{
do_close();
return false;
return true;
}
case menu::errors:
{
Expand Down Expand Up @@ -2601,11 +2605,13 @@ void executor::subscribe_capture()
}

logger("CONSOLE: '" + line + "'");
return !ec;
return true;
},
[&](const code&)
[&](const code& ec)
{
// subscription completion handler.
if (!ec)
unset_console_echo();
});
}

Expand Down
Loading