Restore previous status line after notifying wait for shell

Fixes prompt getting erased by the wait for shell message, and
having to manually trigger a redraw to see it again.
This commit is contained in:
Maxime Coste 2018-04-01 10:08:54 +11:00
parent 0baf562c93
commit ea66465144
2 changed files with 7 additions and 4 deletions

View File

@ -48,6 +48,7 @@ public:
void info_hide(bool even_modal = false);
void print_status(DisplayLine status_line);
const DisplayLine& current_status() { return m_status_line; }
DisplayCoord dimensions() const;

View File

@ -256,20 +256,22 @@ std::pair<String, int> ShellManager::eval(
using namespace std::chrono;
static constexpr seconds wait_timeout{1};
bool wait_notified = false;
Optional<DisplayLine> previous_status;
Timer wait_timer{wait_time + wait_timeout, [&](Timer& timer)
{
auto wait_duration = Clock::now() - wait_time;
if (context.has_client())
{
auto& client = context.client();
if (not previous_status)
previous_status = client.current_status();
client.print_status({ format("waiting for shell command to finish ({}s)",
duration_cast<seconds>(wait_duration).count()),
get_face("Information") });
client.redraw_ifn();
}
timer.set_next_date(Clock::now() + wait_timeout);
wait_notified = true;
}, EventMode::Urgent};
while (not terminated or child_stdin.write_fd() != -1 or
@ -294,9 +296,9 @@ std::pair<String, int> ShellManager::eval(
(size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count()));
}
if (wait_notified and context.has_client()) // clear the status line
if (previous_status) // restore the status line
{
context.print_status({});
context.print_status(std::move(*previous_status));
context.client().redraw_ifn();
}