Skip to content

Commit eaccd8b

Browse files
committed
fix(faces/lucid): emit // (no trailing space) for blank -- lines
When a `--`-comment line has no text (e.g. just `--`), `strip_dashdash_comment` returns `Some ""`. The previous code would emit `"// " ^ "" ^ "\n"` = `"// \n"`, leaving a trailing space. The expected snapshot (and readable output) needs `"//\n"` with no trailing space. Fix: check the trimmed comment text and emit bare `"//"` when it is empty. https://claude.ai/code/session_01Vrh2f1G8tf7ZbNcKh9r5U9
1 parent 801b72c commit eaccd8b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/lucid_face.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,10 @@ let transform_source source =
576576

577577
if stripped = "" then begin
578578
(match comment_opt with
579-
| Some c -> Buffer.add_string out ("// " ^ String.trim c ^ "\n")
580-
| None -> Buffer.add_char out '\n')
579+
| Some c ->
580+
let c' = String.trim c in
581+
Buffer.add_string out (if c' = "" then "//\n" else "// " ^ c' ^ "\n")
582+
| None -> Buffer.add_char out '\n')
581583
end else if starts_with stripped "//" || starts_with stripped "/*" then begin
582584
(* Already-canonical comment lines pass through unchanged. *)
583585
let indent_str = String.make ind ' ' in

0 commit comments

Comments
 (0)