From 3e8b21dcecc2be5f187c17c7b0110f618af5a8f0 Mon Sep 17 00:00:00 2001 From: Dmitrii Kovanikov Date: Mon, 24 Jun 2024 18:57:36 +0100 Subject: [PATCH] Don't redraw the view on exit --- lib/tui/model.ml | 2 ++ lib/tui/update.ml | 3 ++- lib/tui/view.ml | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tui/model.ml b/lib/tui/model.ml index 080fa02..a52be3e 100644 --- a/lib/tui/model.ml +++ b/lib/tui/model.ml @@ -11,6 +11,7 @@ type tab = | PullRequests type t = { + exit : bool; width : int; height : int; repo : string; @@ -31,6 +32,7 @@ let initial_model { repo; root_dir_path; files; width; height } = width; height; repo; + exit = false; current_tab = Code; code_tab = { root_dir_path; fs = Fs.zip_it files }; } diff --git a/lib/tui/update.ml b/lib/tui/update.ml index f470689..ceddd94 100644 --- a/lib/tui/update.ml +++ b/lib/tui/update.ml @@ -28,7 +28,8 @@ let update event (model : Model.t) = match event with (* if we press `q` or the escape key, we exit *) | Event.KeyDown ((Key "q" | Escape), _modifier) -> - (model, Command.(Seq [ Exit_alt_screen; Show_cursor; Quit ])) + ( { model with exit = true }, + Command.(Seq [ Exit_alt_screen; Show_cursor; Quit ]) ) (* if we press a digit, we switch to the corresponding tab *) | Event.KeyDown (Key "1", _modifier) -> ({ model with current_tab = Model.Code }, Command.Noop) diff --git a/lib/tui/view.ml b/lib/tui/view.ml index 78f72ad..7120f22 100644 --- a/lib/tui/view.ml +++ b/lib/tui/view.ml @@ -42,4 +42,5 @@ let to_doc (model : Model.t) = empty; ] -let view (model : Model.t) = model |> to_doc |> Pretty.render ~width:model.width +let view (model : Model.t) = + if model.exit then "" else model |> to_doc |> Pretty.render ~width:model.width