diff --git a/CHANGES.md b/CHANGES.md index cfc420e2a1c6..416e362e19a6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ Unreleased ---------- +- Pre-emptively clear screen in watch mode (#6987, fixes #6884, @rgrinberg) + - Fix cross compilation configuration when a context with targets is itself a host of another context (#6958, fixes #6843, @rgrinberg) diff --git a/bin/common.ml b/bin/common.ml index 39787a15c28d..39da1f027aab 100644 --- a/bin/common.ml +++ b/bin/common.ml @@ -986,7 +986,11 @@ let init ?log_file c = Dune_config.adapt_display config ~output_is_a_tty:(Lazy.force Ansi_color.output_is_a_tty) in - Dune_config.init config; + Dune_config.init config + ~watch: + (match c.builder.watch with + | No -> false + | Yes _ -> true); Dune_engine.Execution_parameters.init (let open Memo.O in let+ w = Dune_rules.Workspace.workspace () in diff --git a/src/dune_config/dune_config.ml b/src/dune_config/dune_config.ml index 0f85b7d60f40..5e3bca7446db 100644 --- a/src/dune_config/dune_config.ml +++ b/src/dune_config/dune_config.ml @@ -382,8 +382,13 @@ let adapt_display config ~output_is_a_tty = { config with terminal_persistence = Terminal_persistence.Preserve } else config -let init t = +let init t ~watch = Console.Backend.set (Display.console_backend t.display); + (if watch then + match t.terminal_persistence with + | Preserve -> () + | Clear_on_rebuild -> Console.reset () + | Clear_on_rebuild_and_flush_history -> Console.reset_flush_history ()); Log.verbose := t.display.verbosity = Verbose let auto_concurrency = diff --git a/src/dune_config/dune_config.mli b/src/dune_config/dune_config.mli index 01022056071b..29e772479467 100644 --- a/src/dune_config/dune_config.mli +++ b/src/dune_config/dune_config.mli @@ -111,7 +111,7 @@ val load_config_file : Path.t -> Partial.t val adapt_display : t -> output_is_a_tty:bool -> t (** Initialises the configuration for the process *) -val init : t -> unit +val init : t -> watch:bool -> unit val to_dyn : t -> Dyn.t