nimpretty: don't touch dense binary operators
This commit is contained in:
parent
dbcdc4331a
commit
98f3daea65
1 changed files with 12 additions and 8 deletions
|
|
@ -104,7 +104,7 @@ proc softLinebreak(em: var Emitter, lit: string) =
|
||||||
proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
|
proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
|
||||||
|
|
||||||
template endsInWhite(em): bool =
|
template endsInWhite(em): bool =
|
||||||
em.content.len > 0 and em.content[em.content.high] in {' ', '\L'}
|
em.content.len == 0 or em.content[em.content.high] in {' ', '\L'}
|
||||||
template endsInAlpha(em): bool =
|
template endsInAlpha(em): bool =
|
||||||
em.content.len > 0 and em.content[em.content.high] in SymChars+{'_'}
|
em.content.len > 0 and em.content[em.content.high] in SymChars+{'_'}
|
||||||
|
|
||||||
|
|
@ -203,6 +203,10 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
|
||||||
wr(TokTypeToStr[tok.tokType])
|
wr(TokTypeToStr[tok.tokType])
|
||||||
wr(" ")
|
wr(" ")
|
||||||
of tkOpr, tkDotDot:
|
of tkOpr, tkDotDot:
|
||||||
|
if tok.strongSpaceA == 0 and tok.strongSpaceB == 0:
|
||||||
|
# if not surrounded by whitespace, don't produce any whitespace either:
|
||||||
|
wr(tok.ident.s)
|
||||||
|
else:
|
||||||
if not em.endsInWhite: wr(" ")
|
if not em.endsInWhite: wr(" ")
|
||||||
wr(tok.ident.s)
|
wr(tok.ident.s)
|
||||||
template isUnary(tok): bool =
|
template isUnary(tok): bool =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue