diff --git a/minidebug_runtime.ml b/minidebug_runtime.ml index b5aeca4..3856b7a 100644 --- a/minidebug_runtime.ml +++ b/minidebug_runtime.ml @@ -502,6 +502,7 @@ module PrintBox (Log_to : Shared_config) = struct type subentry = { result_id : int; is_result : bool; + highlighted : bool; elapsed_start : Mtime.span; elapsed_end : Mtime.span; subtree : B.t; @@ -642,6 +643,7 @@ module PrintBox (Log_to : Shared_config) = struct (fun { result_id; is_result; _ } -> is_result && result_id = entry_id) body in + let results_hl = List.exists (fun { highlighted; _ } -> highlighted) results in let results = unpack ~f:(fun { subtree; _ } -> subtree) results and body = unpack ~f:(fun { subtree; _ } -> subtree) body in match results with @@ -657,7 +659,8 @@ module PrintBox (Log_to : Shared_config) = struct (apply_highlight highlight value_header) (b_path :: B.tree - (B.line @@ if body = [] then "" else "") + (apply_highlight results_hl @@ B.line + @@ if body = [] then "" else "") (Array.to_list result_body) :: opt_message @ body) ) @@ -674,7 +677,10 @@ module PrintBox (Log_to : Shared_config) = struct ( header, B.tree hl_header @@ b_path - :: B.tree (B.line @@ if body = [] then "" else "") results + :: B.tree + (apply_highlight results_hl @@ B.line + @@ if body = [] then "" else "") + results :: body ) else let hl_header = @@ -904,6 +910,7 @@ module PrintBox (Log_to : Shared_config) = struct { result_id; is_result = false; + highlighted = hl; elapsed_start; elapsed_end = elapsed_on_close; subtree; @@ -1007,6 +1014,7 @@ module PrintBox (Log_to : Shared_config) = struct { result_id = entry_id; is_result; + highlighted = hl; elapsed_start = elapsed; elapsed_end = elapsed; subtree = b; @@ -1024,6 +1032,7 @@ module PrintBox (Log_to : Shared_config) = struct { result_id = entry_id; is_result; + highlighted = hl; elapsed_start = elapsed; elapsed_end = elapsed; subtree = b; diff --git a/test/test_expect_test.ml b/test/test_expect_test.ml index 3ba41b5..093c7f1 100644 --- a/test/test_expect_test.ml +++ b/test/test_expect_test.ml @@ -3876,3 +3876,78 @@ let%expect_test "%track_rt_show expression runtime passing" = t2 test B end BEGIN DEBUG SESSION t3 |}] + +let%expect_test "%debug_show tuples values_first_mode highlighted" = + let module Debug_runtime = + (val Minidebug_runtime.debug + ~highlight_terms:Re.(alt [ str "339"; str "8" ]) + ~values_first_mode:true ()) + in + let%debug_show bar ((first : int), (second : int)) : int = + let y : int = first + 1 in + second * y + in + let () = print_endline @@ Int.to_string @@ bar (7, 42) in + let baz ((first, second) : int * int) : int * int = + let (y, z) : int * int = (first + 1, 3) in + let (a : int), (b : int) = (first + 1, second + 3) in + ((second * y) + z, (a * a) + b) + in + let r1, r2 = (baz (7, 42) : int * int) in + let () = print_endline @@ Int.to_string r1 in + let () = print_endline @@ Int.to_string r2 in + [%expect + {| + BEGIN DEBUG SESSION + ┌─────────┐ + │bar = 336│ + ├─────────┘ + ├─"test/test_expect_test.ml":3886:21 + ├─first = 7 + ├─second = 42 + └─┬─────┐ + │y = 8│ + ├─────┘ + └─"test/test_expect_test.ml":3887:8 + 336 + ┌────────┐ + │(r1, r2)│ + ├────────┘ + ├─"test/test_expect_test.ml":3896:6 + ├─┬─────────┐ + │ ││ + │ ├─────────┘ + │ ├─┬────────┐ + │ │ │r1 = 339│ + │ │ └────────┘ + │ └─r2 = 109 + └─┬────────────────┐ + │baz = (339, 109)│ + ├────────────────┘ + ├─"test/test_expect_test.ml":3891:10 + ├─first = 7 + ├─second = 42 + ├─┬──────┐ + │ │(y, z)│ + │ ├──────┘ + │ ├─"test/test_expect_test.ml":3892:8 + │ └─┬────────┐ + │ ││ + │ ├────────┘ + │ ├─┬─────┐ + │ │ │y = 8│ + │ │ └─────┘ + │ └─z = 3 + └─┬──────┐ + │(a, b)│ + ├──────┘ + ├─"test/test_expect_test.ml":3893:8 + └─┬────────┐ + ││ + ├────────┘ + ├─┬─────┐ + │ │a = 8│ + │ └─────┘ + └─b = 45 + 339 + 109 |}]