diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 9f9b6fc8ec..f96f88da1e 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -111,15 +111,16 @@ proc softLinebreak(em: var Emitter, lit: string) = for i in 1..em.indentLevel+moreIndent(em): wr(" ") else: # search backwards for a good split position: - for a in em.altSplitPos: + for a in mitems(em.altSplitPos): if a > em.fixedUntil: var spaces = 0 while a+spaces < em.content.len and em.content[a+spaces] == ' ': inc spaces if spaces > 0: delete(em.content, a, a+spaces-1) - let ws = "\L" & repeat(' ',em.indentLevel+moreIndent(em)) em.col = em.content.len - a + let ws = "\L" & repeat(' ', em.indentLevel+moreIndent(em)) em.content.insert(ws, a) + a = -1 break proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) = @@ -256,8 +257,8 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) = tok.strongSpaceB == 0 and tok.strongSpaceA > 0 if not isUnary(tok): - wr(" ") rememberSplit(splitBinary) + wr(" ") of tkAccent: if not em.inquote and endsInAlpha(em): wr(" ") wr(TokTypeToStr[tok.tokType]) diff --git a/nimpretty/tester.nim b/nimpretty/tester.nim index d940714910..6d329f3972 100644 --- a/nimpretty/tester.nim +++ b/nimpretty/tester.nim @@ -17,7 +17,9 @@ else: proc test(infile, ext: string) = if execShellCmd("$# -o:$# --backup:off $#" % [nimp, infile.changeFileExt(ext), infile]) != 0: - quit("FAILURE") + echo "FAILURE: nimpretty cannot prettify ", infile + failures += 1 + return let nimFile = splitFile(infile).name let expected = dir / "expected" / nimFile & ".nim" let produced = dir / nimFile.changeFileExt(ext) diff --git a/nimpretty/tests/expected/simple3.nim b/nimpretty/tests/expected/simple3.nim index f05c361adf..7f17e0fc6c 100644 --- a/nimpretty/tests/expected/simple3.nim +++ b/nimpretty/tests/expected/simple3.nim @@ -7,3 +7,10 @@ foo bar proc fun() = echo "ok1" + +proc fun2(a = "fooo" & "bar" & "bar" & "bar" & "bar" & ( + "bar" & "bar" & "bar") & "bar" & "bar" & "bar" & "bar" & "bar" & "bar" & + "bar" & "bar" & "bar"): auto = + discard + +fun2() diff --git a/nimpretty/tests/simple3.nim b/nimpretty/tests/simple3.nim index f05c361adf..bd60ddf399 100644 --- a/nimpretty/tests/simple3.nim +++ b/nimpretty/tests/simple3.nim @@ -7,3 +7,8 @@ foo bar proc fun() = echo "ok1" + +proc fun2(a = "fooo" & "bar" & "bar" & "bar" & "bar" & ("bar" & "bar" & "bar") & "bar" & "bar" & "bar" & "bar" & "bar" & "bar" & "bar" & "bar" & "bar"): auto = + discard + +fun2()