summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2023-02-21 10:04:22 +0100
committerGabriel Scherer <gabriel.scherer@gmail.com>2023-02-23 22:20:08 +0100
commit165b1796563674addd46f820ebbad3fac66b9ece (patch)
tree9d108e2ebf5fd51d70fa816d3296b0c66abdfaa1
parent71aef9e0494819ed3d200439408e96963c7d4103 (diff)
downloadocaml-165b1796563674addd46f820ebbad3fac66b9ece.tar.gz
print a blank line between consecutive warnings/errors
-rw-r--r--parsing/location.ml14
-rw-r--r--testsuite/tools/expect_test.ml1
2 files changed, 15 insertions, 0 deletions
diff --git a/parsing/location.ml b/parsing/location.ml
index c9c0401edb..6326e80e90 100644
--- a/parsing/location.ml
+++ b/parsing/location.ml
@@ -95,9 +95,20 @@ let setup_terminal () =
input in the terminal. This would not be possible without this information,
since printing several warnings/errors adds text between the user input and
the bottom of the terminal.
+
+ We also use for {!is_first_report}, see below.
*)
let num_loc_lines = ref 0
+(* We use [num_loc_lines] to determine if the report about to be
+ printed is the first or a follow-up report of the current
+ "batch" -- contiguous reports without user input in between, for
+ example for the current toplevel phrase. We use this to print
+ a blank line between messages of the same batch.
+*)
+let is_first_message () =
+ !num_loc_lines = 0
+
(* This is used by the toplevel to reset [num_loc_lines] before each phrase *)
let reset () =
num_loc_lines := 0
@@ -730,6 +741,9 @@ let batch_mode_printer : report_printer =
let pp_txt ppf txt = Format.fprintf ppf "@[%t@]" txt in
let pp self ppf report =
setup_colors ();
+ (* Print a blank line between consecutive reports. *)
+ if not (is_first_message ()) then
+ Format.pp_print_newline ppf ();
(* Make sure we keep [num_loc_lines] updated.
The tabulation box is here to give submessage the option
to be aligned with the main message box
diff --git a/testsuite/tools/expect_test.ml b/testsuite/tools/expect_test.ml
index 8ac0e8cbb3..b76e77c1e4 100644
--- a/testsuite/tools/expect_test.ml
+++ b/testsuite/tools/expect_test.ml
@@ -163,6 +163,7 @@ let capture_everything buf ppf ~f =
~f:(fun () -> Compiler_messages.capture ppf ~f)
let exec_phrase ppf phrase =
+ Location.reset ();
if !Clflags.dump_parsetree then Printast. top_phrase ppf phrase;
if !Clflags.dump_source then Pprintast.top_phrase ppf phrase;
Toploop.execute_phrase true ppf phrase