Skip to content

Commit 2f5b500

Browse files
committed
FIX: MOLD/FLAT on event values does not remove line breaks
fixes: metaeducation/rebol-issues#2387
1 parent 594ecbf commit 2f5b500

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/core/t-event.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,18 @@ enum rebol_event_fields {
513513
SYM_TYPE, SYM_PORT, SYM_GOB, SYM_OFFSET, SYM_KEY,
514514
SYM_FLAGS, SYM_CODE, SYM_DATA, 0
515515
};
516+
REBOOL indented = !GET_MOPT(mold, MOPT_INDENT);
516517

517518
Pre_Mold(value, mold);
518519
Append_Byte(mold->series, '[');
519520
mold->indent++;
520521

521522
for (field = 0; fields[field]; field++) {
522523
if (Get_Event_Var(value, fields[field], &val) && !IS_NONE(&val)) {
523-
New_Indented_Line(mold);
524+
if(indented)
525+
New_Indented_Line(mold);
526+
else if (field > 0)
527+
Append_Byte(mold->series, ' ');
524528
Append_UTF8(mold->series, Get_Sym_Name(fields[field]), -1);
525529
Append_Bytes(mold->series, ": ");
526530
if (IS_WORD(&val)) Append_Byte(mold->series, '\'');
@@ -529,7 +533,7 @@ enum rebol_event_fields {
529533
}
530534

531535
mold->indent--;
532-
New_Indented_Line(mold);
536+
if (indented) New_Indented_Line(mold);
533537
Append_Byte(mold->series, ']');
534538

535539
End_Mold(mold);

src/tests/units/mold-test.r3

+9
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,13 @@ Rebol [
227227

228228
===end-group===
229229

230+
===start-group=== "mold event!"
231+
232+
--test-- "mold/flat event!"
233+
;@@ https://github.com/rebol/rebol-issues/issues/2387
234+
--assert "make event! [type: 'lookup]" = mold/flat make event! [type: 'lookup]
235+
236+
237+
===end-group===
238+
230239
~~~end-file~~~

0 commit comments

Comments
 (0)