@@ -30,8 +30,7 @@ let pp_left_pad n s =
3030;;
3131
3232let pp_line padding_width (lnum , l ) =
33- let open Pp.O in
34- pp_left_pad padding_width lnum ++ Pp. verbatim " | " ++ Pp. verbatim l ++ Pp. newline
33+ Pp. concat [ pp_left_pad padding_width lnum; Pp. verbatim " | " ; Pp. verbatim l ]
3534;;
3635
3736type tag = Loc
@@ -51,11 +50,14 @@ let pp_file_excerpt ~context_lines ~max_lines_to_print_in_full loc : tag Pp.t =
5150 let padding_width = String. length line_num_str in
5251 let * line = Result. try_with (fun () -> Io.String_path. file_line file line_num) in
5352 let len = stop_c - start_c in
54- let open Pp.O in
5553 Ok
56- (pp_line padding_width (line_num_str, line)
57- ++ pp_left_pad (stop_c + padding_width + 3 ) (String. make len '^' )
58- ++ Pp. newline)
54+ (Pp. vbox
55+ @@ Pp. concat
56+ ~sep: Pp. cut
57+ [ pp_line padding_width (line_num_str, line)
58+ ; pp_left_pad (stop_c + padding_width + 3 ) (String. make len '^' )
59+ ; Pp. nop
60+ ])
5961 | `Multiline ->
6062 let get_padding lines =
6163 let lnum, _ = Option. value_exn (List. last lines) in
@@ -64,12 +66,10 @@ let pp_file_excerpt ~context_lines ~max_lines_to_print_in_full loc : tag Pp.t =
6466 let print_ellipsis padding_width =
6567 (* We add 2 to the width of max line to account for the extra space and
6668 the `|` character at the end of a line number *)
67- let line = String. make (padding_width + 2 ) '.' in
68- let open Pp.O in
69- Pp. verbatim line ++ Pp. newline
69+ Pp. verbatim (String. make (padding_width + 2 ) '.' )
7070 in
7171 let print_lines lines padding_width =
72- Pp. concat_map lines ~f: (pp_line padding_width)
72+ Pp. concat_map lines ~sep: Pp. cut ~ f: (pp_line padding_width)
7373 in
7474 let file_lines ~start ~stop =
7575 Result. try_with (fun () -> Io.String_path. file_lines file ~start ~stop )
@@ -90,10 +90,14 @@ let pp_file_excerpt ~context_lines ~max_lines_to_print_in_full loc : tag Pp.t =
9090 file_lines ~start: (stop.pos_lnum - context_lines) ~stop: stop.pos_lnum
9191 in
9292 let padding_width = get_padding last_shown_lines in
93- let open Pp.O in
94- print_lines first_shown_lines padding_width
95- ++ print_ellipsis padding_width
96- ++ print_lines last_shown_lines padding_width
93+ Pp. vbox
94+ @@ Pp. concat
95+ ~sep: Pp. cut
96+ [ print_lines first_shown_lines padding_width
97+ ; print_ellipsis padding_width
98+ ; print_lines last_shown_lines padding_width
99+ ; Pp. nop
100+ ]
97101 in
98102 let whole_file = start_c = 0 && stop_c = 0 in
99103 if whole_file
@@ -125,18 +129,21 @@ let pp loc =
125129 then Printf. sprintf " line %d" start.pos_lnum
126130 else Printf. sprintf " lines %d-%d" start.pos_lnum stop.pos_lnum
127131 in
128- let open Pp.O in
129- Pp. tag
130- Loc
131- (Pp. verbatim
132- (Printf. sprintf
133- " File \" %s\" , %s, characters %d-%d:"
134- start.pos_fname
135- lnum
136- start_c
137- stop_c))
138- ++ Pp. newline
139- ++ pp_file_excerpt ~context_lines: 2 ~max_lines_to_print_in_full: 10 loc
132+ Pp. vbox
133+ @@ Pp. concat
134+ ~sep: Pp. cut
135+ [ Pp. tag
136+ Loc
137+ (Pp. hovbox
138+ (Pp. textf
139+ " File \" %s\" , %s, characters %d-%d:"
140+ start.pos_fname
141+ lnum
142+ start_c
143+ stop_c))
144+ ; pp_file_excerpt ~context_lines: 2 ~max_lines_to_print_in_full: 10 loc
145+ ; Pp. nop
146+ ]
140147;;
141148
142149let on_same_line loc1 loc2 =
0 commit comments