diff options
author | Araq <rumpf_a@web.de> | 2019-06-07 12:59:31 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-06-07 12:59:31 +0200 |
commit | 667af87e66ed1ad4f3dbe455df72257d21fbc426 (patch) | |
tree | 82d0b6801b2ece271706f5d677053a88472071fe /compiler | |
parent | 790bc5b07bd192d4ddd2bcd08179e8cd82236f55 (diff) | |
download | Nim-667af87e66ed1ad4f3dbe455df72257d21fbc426.tar.gz |
nimpretty: fixes #9505 [bugfix]
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/layouter.nim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim index ddcb5a976..336b09fa7 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -113,6 +113,10 @@ const openPars = {tkParLe, tkParDotLe, tkBracketLe, tkBracketLeColon, tkCurlyDotLe, tkCurlyLe} + closedPars = {tkParRi, tkParDotRi, + tkBracketRi, tkCurlyDotRi, + tkCurlyRi} + splitters = openPars + {tkComma, tkSemicolon} oprSet = {tkOpr, tkDiv, tkMod, tkShl, tkShr, tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs, tkDotDot, tkAnd, tkOr, tkXor} @@ -196,8 +200,12 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) = em.fixedUntil = em.content.high elif tok.indent >= 0: - if em.lastTok in (splitters + oprSet) or em.keepIndents > 0: + if em.keepIndents > 0: em.indentLevel = tok.indent + elif (em.lastTok in (splitters + oprSet) and tok.tokType notin closedPars): + # aka: we are in an expression context: + let alignment = tok.indent - em.indentStack[^1] + em.indentLevel = alignment + em.indentStack.high * em.indWidth else: if tok.indent > em.indentStack[^1]: em.indentStack.add tok.indent |