From ea664651448a7f2f5f2fb3dc15c804c0ba7f95f0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 1 Apr 2018 10:08:54 +1100 Subject: [PATCH] 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. --- src/client.hh | 1 + src/shell_manager.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client.hh b/src/client.hh index 3d90a247..dadc0320 100644 --- a/src/client.hh +++ b/src/client.hh @@ -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; diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 47bfd101..2d0744e0 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -256,20 +256,22 @@ std::pair ShellManager::eval( using namespace std::chrono; static constexpr seconds wait_timeout{1}; - bool wait_notified = false; + Optional 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(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 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(); }