diff --git a/CHANGES.md b/CHANGES.md index cfc420e2a1c..416e362e19a 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 39787a15c28..39da1f027aa 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/bin/subst.ml b/bin/subst.ml index 4f50a8bb3b4..840f7bee811 100644 --- a/bin/subst.ml +++ b/bin/subst.ml @@ -433,7 +433,7 @@ let term = Path.set_root (Path.External.cwd ()); Path.Build.set_build_dir (Path.Outside_build_dir.of_string Common.default_build_dir); - Dune_config.init config; + Dune_config.init config ~watch:false; Log.init_disabled (); Dune_engine.Scheduler.Run.go ~on_event:(fun _ _ -> ()) diff --git a/src/dune_config/dune_config.ml b/src/dune_config/dune_config.ml index 0f85b7d60f4..5e3bca7446d 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 01022056071..29e77247946 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