diff --git a/src/tui/shell.cpp b/src/tui/shell.cpp index 8601da4..e3e3fb8 100644 --- a/src/tui/shell.cpp +++ b/src/tui/shell.cpp @@ -296,6 +296,7 @@ void Tui::Source(const std::string &filename) { loading_executed = 0; loading_lineno = 0; loading_prev_in_source = in_source; + source_origin_screen = screen_idx; // a sourced line that leaves this screen aborts in_source = true; loading = true; @@ -346,10 +347,10 @@ void Tui::ProcessNextSourceLine() { Submit(); ++loading_executed; - if (screen_idx != 0) { + if (screen_idx != source_origin_screen) { Print("source: line " + std::to_string(loading_lineno) + " is interactive (would open a screen) — aborting."); - screen_idx = 0; + screen_idx = source_origin_screen; loading.store(false); tick_in_flight.store(false); in_source = loading_prev_in_source; diff --git a/src/tui/tui.hpp b/src/tui/tui.hpp index 63861a8..ff01484 100644 --- a/src/tui/tui.hpp +++ b/src/tui/tui.hpp @@ -103,6 +103,7 @@ class Tui { int loading_executed; int loading_lineno; bool loading_prev_in_source; + int source_origin_screen = 0; ///< screen a `source` started from; a sourced line that navigates away (opens an interactive screen) aborts it. ftxui::ScreenInteractive *screen_ptr; ///< set in Run() so Source() can post events. // ---- Dashboard scroll state (0 = top; grows as the user scrolls down) ----