From 014bdb4a05d8f19037dc872a8ea5d48f301d78b6 Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sat, 27 Apr 2024 11:18:35 +0200 Subject: [PATCH] Flush before applying a new configuration. (#848) This avoids an ordering problem with whatever the user printed and interacting with termios/WinAPI. Bug:https://github.com/ArthurSonzogni/FTXUI/issues/846 --- src/ftxui/component/screen_interactive.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 1e1125f..07616d4 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -568,8 +568,16 @@ ScreenInteractive* ScreenInteractive::Active() { // private void ScreenInteractive::Install() { + frame_valid_ = false; + // Flush the buffer for stdout to ensure whatever the user has printed before + // is fully applied before we start modifying the terminal configuration. This + // is important, because we are using two different channels (stdout vs + // termios/WinAPI) to communicate with the terminal emulator below. See + // https://github.com/ArthurSonzogni/FTXUI/issues/846 + Flush(); + // After uninstalling the new configuration, flush it to the terminal to // ensure it is fully applied: on_exit_functions.push([] { Flush(); });