Skip to content

Commit

Permalink
Fix duplicate lines
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz committed Jan 14, 2025
1 parent 2faf732 commit f99b977
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ocamlutil/pretty.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ type doc =
(* Replaces an earlier implementation that relied on repeatedly calling sub, with one inspired by the standard library *)
let breakString init s =
if s = "" then
Nil
init
else
let r = ref init in
let j = ref (String.length s) in
for i = String.length s - 1 downto 0 do
let text = Text (String.sub s (i + 1) (!j - i - 1)) in
if String.unsafe_get s i = '\n' then begin
if !r = Nil then
r := Concat(Line, text)
let text = (String.sub s (i + 1) (!j - i - 1)) in
(if !r = Nil then
r := CText(Line, text)
else
r := Concat(Line, Concat(text, !r));
r := Concat(Line, CText(!r, text)));
j := i
end
done;
let text = Text (String.sub s 0 !j) in
let text = String.sub s 0 !j in
if !r = Nil then
text
Text text
else
Concat(text, Concat(Line, !r))
CText(!r, text)


let nil = Nil
Expand Down

0 comments on commit f99b977

Please sign in to comment.