@@ -18,30 +18,27 @@ let[@tail_mod_cons] rec drop_last_empty =
18
18
| [" " ] -> []
19
19
| x :: xs -> x :: (drop_last_empty[@ tailcall]) xs
20
20
21
+ let indent_decorations len i =
22
+ match len, i with
23
+ | 1 , _ -> " ꭍ"
24
+ | _ , 0 -> " ╭"
25
+ | n , i when i = n-1 -> " ╯"
26
+ | _ -> " ┆"
27
+
21
28
let highlight fmt = " @<0>%s" ^^ fmt ^^ " @<0>%s"
22
29
23
30
let indentf ~param fmt =
24
31
Format. kasprintf @@ fun s ->
25
32
let lines = drop_last_empty @@ String. split_on_char '\n' s in
33
+ let num_lines = List. length lines in
26
34
let p m line =
27
- Format. fprintf fmt (" " ^^ highlight " %s" ^^ " %s@." )
35
+ Format. fprintf fmt (" " ^^ highlight " @<1> %s" ^^ " %s@." )
28
36
(Ansi. style_string ~param TtyStyle. indentation)
29
37
m
30
38
(Ansi. reset_string ~param TtyStyle. indentation)
31
39
line
32
40
in
33
- match lines with
34
- | [] -> ()
35
- | [line] -> p " ꭍ" line
36
- | line :: lines -> p " ╭" line;
37
- let rec go =
38
- function
39
- | [] -> assert false
40
- | [line] -> p " ╯" line;
41
- | line :: lines -> p " ┆" line;
42
- go lines
43
- in
44
- go lines
41
+ List. iteri (fun i line -> p (indent_decorations num_lines i) line) lines
45
42
46
43
(* different parts of the display *)
47
44
@@ -133,7 +130,7 @@ let render_unlocated_tag ~severity ~ansi fmt ((_, text) as tag) =
133
130
text
134
131
(Ansi. reset_string ~param: ansi st)
135
132
136
- module TopLevelRenderer :
133
+ module DiagnosticRenderer :
137
134
sig
138
135
type param =
139
136
{
@@ -200,9 +197,9 @@ struct
200
197
let d = if show_backtrace then d else {d with Diagnostic. backtrace = Emp } in
201
198
let d = Diagnostic. map Message. short_code d in
202
199
let ansi = Ansi.Test. guess ?use_ansi ?use_color output in
203
- let param = {TopLevelRenderer . line_breaking; block_splitting_threshold; tab_size; ansi} in
200
+ let param = {DiagnosticRenderer . line_breaking; block_splitting_threshold; tab_size; ansi} in
204
201
let fmt = Format. formatter_of_out_channel output in
205
202
SourceReader. run @@ fun () ->
206
- TopLevelRenderer . render_diagnostic ~param fmt d;
203
+ DiagnosticRenderer . render_diagnostic ~param fmt d;
207
204
Format. pp_print_newline fmt ()
208
205
end
0 commit comments