Skip to content

Commit 87c5fe5

Browse files
committed
FIX: MOLD NEW-LINE? behavior indents too much in BLOCK!s
resolves: Oldes/Rebol-issues#2279
1 parent d2583a5 commit 87c5fe5

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/core/s-mold.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
674674

675675
if (sep[1]) {
676676
Append_Byte(out, sep[0]);
677-
mold->indent++;
678677
}
679678
// else out->tail--; // why?????
680679

@@ -683,8 +682,14 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
683682
// check if we can end sooner with molding..
684683
if (MOLD_HAS_LIMIT(mold) && MOLD_OVER_LIMIT(mold)) return;
685684
if (VAL_GET_LINE(value)) {
686-
if (indented && (sep[1] || line_flag)) New_Indented_Line(mold);
687-
had_lines = TRUE;
685+
if (indented && (sep[1] || line_flag)) {
686+
if(!had_lines && !line_flag) {
687+
had_lines = TRUE;
688+
mold->indent++;
689+
}
690+
New_Indented_Line(mold);
691+
}
692+
688693
}
689694
line_flag = TRUE;
690695
Mold_Value(mold, value, TRUE);
@@ -694,8 +699,10 @@ STOID Mold_Block_Series(REB_MOLD *mold, REBSER *series, REBCNT index, REBYTE *se
694699
}
695700

696701
if (sep[1]) {
697-
mold->indent--;
698-
if (indented && (VAL_GET_LINE(value) || had_lines)) New_Indented_Line(mold);
702+
if (indented && (VAL_GET_LINE(value) || had_lines)) {
703+
if (had_lines) mold->indent--;
704+
New_Indented_Line(mold);
705+
}
699706
Append_Byte(out, sep[1]);
700707
}
701708

src/tests/units/mold-test.r3

+4
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ Rebol [
291291
--assert "1 2^/3^/4" = mold/only load "[1 2^/3^/4^/]"
292292
--assert "1 2^/3^/4^/5" = mold/only load "[1 2^/3^/4^/5]"
293293

294+
--test-- "issue-2279"
295+
;@@ https://github.com/Oldes/Rebol-issues/issues/2279
296+
--assert "[[[^/ 1^/]]]" = mold load {[[[^/1^/]]]}
297+
294298
===end-group===
295299

296300
===start-group=== "mold map!"

0 commit comments

Comments
 (0)