Skip to content

Commit eb3f2f6

Browse files
committed
fix(lucid-face): strip extra trailing newline from transform_source
When source ends with \n, String.split_on_char '\n' produces a trailing empty string. The loop processes it as an empty line, emitting an extra \n via Buffer.add_char — making output end with \n\n instead of \n. Strip the redundant newline at the end of transform_source so the output matches the snapshot (which was already updated to have exactly one trailing newline). https://claude.ai/code/session_01Vrh2f1G8tf7ZbNcKh9r5U9
1 parent eaccd8b commit eb3f2f6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/lucid_face.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,10 @@ let transform_source source =
658658
for _ = 1 to !toplevel_braces do
659659
Buffer.add_string out "}\n"
660660
done;
661-
Buffer.contents out
661+
let s = Buffer.contents out in
662+
let l = String.length s in
663+
if l >= 2 && s.[l-1] = '\n' && s.[l-2] = '\n' then String.sub s 0 (l-1)
664+
else s
662665

663666
(* ─── Entry points ────────────────────────────────────────────────────────────── *)
664667

0 commit comments

Comments
 (0)