Skip to content

Commit f99b977

Browse files
Fix duplicate lines
1 parent 2faf732 commit f99b977

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ocamlutil/pretty.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ type doc =
7373
(* Replaces an earlier implementation that relied on repeatedly calling sub, with one inspired by the standard library *)
7474
let breakString init s =
7575
if s = "" then
76-
Nil
76+
init
7777
else
7878
let r = ref init in
7979
let j = ref (String.length s) in
8080
for i = String.length s - 1 downto 0 do
81-
let text = Text (String.sub s (i + 1) (!j - i - 1)) in
8281
if String.unsafe_get s i = '\n' then begin
83-
if !r = Nil then
84-
r := Concat(Line, text)
82+
let text = (String.sub s (i + 1) (!j - i - 1)) in
83+
(if !r = Nil then
84+
r := CText(Line, text)
8585
else
86-
r := Concat(Line, Concat(text, !r));
86+
r := Concat(Line, CText(!r, text)));
8787
j := i
8888
end
8989
done;
90-
let text = Text (String.sub s 0 !j) in
90+
let text = String.sub s 0 !j in
9191
if !r = Nil then
92-
text
92+
Text text
9393
else
94-
Concat(text, Concat(Line, !r))
94+
CText(!r, text)
9595

9696

9797
let nil = Nil

0 commit comments

Comments
 (0)