summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-06-20 00:56:29 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-06-20 00:56:29 +0200
commit0725003a8cdb90e149d91fc6c5affcb270223be7 (patch)
tree5ac1cfd2b688ccd8516b60b88ff50081d37ce502
parent26568dff004cf210736cccc8103ce6f2d47cb82f (diff)
downloadNim-0725003a8cdb90e149d91fc6c5affcb270223be7.tar.gz
nimpretty: fixes more reported issues
-rw-r--r--compiler/layouter.nim7
-rw-r--r--nimpretty/tests/exhaustive.nim3
-rw-r--r--nimpretty/tests/expected/exhaustive.nim3
3 files changed, 10 insertions, 3 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim
index d0c9a77b9..409b656c9 100644
--- a/compiler/layouter.nim
+++ b/compiler/layouter.nim
@@ -169,7 +169,7 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
   of tokKeywordLow..tokKeywordHigh:
     if endsInAlpha(em):
       wr(" ")
-    elif not em.inquote and not endsInWhite(em):
+    elif not em.inquote and not endsInWhite(em) and tok.tokType in oprSet:
       wr(" ")
 
     if not em.inquote:
@@ -207,9 +207,9 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
      tkColonColon, tkDot:
     wr(TokTypeToStr[tok.tokType])
   of tkEquals:
-    if not em.endsInWhite: wr(" ")
+    if not em.inquote and not em.endsInWhite: wr(" ")
     wr(TokTypeToStr[tok.tokType])
-    wr(" ")
+    if not em.inquote: wr(" ")
   of tkOpr, tkDotDot:
     if tok.strongSpaceA == 0 and tok.strongSpaceB == 0:
       # if not surrounded by whitespace, don't produce any whitespace either:
@@ -224,6 +224,7 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
         wr(" ")
         rememberSplit(splitBinary)
   of tkAccent:
+    if not em.inquote and endsInAlpha(em): wr(" ")
     wr(TokTypeToStr[tok.tokType])
     em.inquote = not em.inquote
   of tkComment:
diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim
index 1039e308b..bca42d4d4 100644
--- a/nimpretty/tests/exhaustive.nim
+++ b/nimpretty/tests/exhaustive.nim
@@ -5,6 +5,9 @@ discard """
 
 import verylongnamehere,verylongnamehere,verylongnamehereverylongnamehereverylong,namehere,verylongnamehere
 
+proc `[]=`() = discard "index setter"
+proc `putter=`() = discard cast[pointer](cast[int](buffer) + size)
+
 type
   GeneralTokenizer* = object of RootObj ## comment here
     kind*: TokenClass ## and here
diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim
index 8f8a03b0b..4520fb9bd 100644
--- a/nimpretty/tests/expected/exhaustive.nim
+++ b/nimpretty/tests/expected/exhaustive.nim
@@ -6,6 +6,9 @@ discard """
 import verylongnamehere, verylongnamehere,
   verylongnamehereverylongnamehereverylong, namehere, verylongnamehere
 
+proc `[]=`() = discard "index setter"
+proc `putter=`() = discard cast[pointer](cast[int](buffer) + size)
+
 type
   GeneralTokenizer* = object of RootObj ## comment here
     kind*: TokenClass         ## and here