Skip to content

Commit

Permalink
FIX: MOLD/FLAT on event values does not remove line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Sep 23, 2019
1 parent 594ecbf commit 2f5b500
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/t-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,18 @@ enum rebol_event_fields {
SYM_TYPE, SYM_PORT, SYM_GOB, SYM_OFFSET, SYM_KEY,
SYM_FLAGS, SYM_CODE, SYM_DATA, 0
};
REBOOL indented = !GET_MOPT(mold, MOPT_INDENT);

Pre_Mold(value, mold);
Append_Byte(mold->series, '[');
mold->indent++;

for (field = 0; fields[field]; field++) {
if (Get_Event_Var(value, fields[field], &val) && !IS_NONE(&val)) {
New_Indented_Line(mold);
if(indented)
New_Indented_Line(mold);
else if (field > 0)
Append_Byte(mold->series, ' ');
Append_UTF8(mold->series, Get_Sym_Name(fields[field]), -1);
Append_Bytes(mold->series, ": ");
if (IS_WORD(&val)) Append_Byte(mold->series, '\'');
Expand All @@ -529,7 +533,7 @@ enum rebol_event_fields {
}

mold->indent--;
New_Indented_Line(mold);
if (indented) New_Indented_Line(mold);
Append_Byte(mold->series, ']');

End_Mold(mold);
Expand Down
9 changes: 9 additions & 0 deletions src/tests/units/mold-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,13 @@ Rebol [

===end-group===

===start-group=== "mold event!"

--test-- "mold/flat event!"
;@@ https://github.com/rebol/rebol-issues/issues/2387
--assert "make event! [type: 'lookup]" = mold/flat make event! [type: 'lookup]


===end-group===

~~~end-file~~~

0 comments on commit 2f5b500

Please sign in to comment.