diff options
Diffstat (limited to 'compiler/layouter.nim')
-rw-r--r-- | compiler/layouter.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 367d2aead..0c888b455 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -9,10 +9,7 @@ ## Layouter for nimpretty. -import idents, lexer, lineinfos, llstream, options, msgs, strutils, - pathutils -from os import changeFileExt -from sequtils import delete +import idents, lexer, lineinfos, llstream, options, msgs, strutils, pathutils const MinLineLen = 15 @@ -314,11 +311,11 @@ proc removeSpaces(em: var Emitter) = const openPars = {tkParLe, tkParDotLe, - tkBracketLe, tkBracketLeColon, tkCurlyDotLe, - tkCurlyLe} + tkBracketLe, tkBracketDotLe, tkBracketLeColon, + tkCurlyDotLe, tkCurlyLe} closedPars = {tkParRi, tkParDotRi, - tkBracketRi, tkCurlyDotRi, - tkCurlyRi, tkBracketDotRi} + tkBracketRi, tkBracketDotRi, + tkCurlyDotRi, tkCurlyRi} splitters = openPars + {tkComma, tkSemiColon} # do not add 'tkColon' here! oprSet = {tkOpr, tkDiv, tkMod, tkShl, tkShr, tkIn, tkNotin, tkIs, @@ -444,6 +441,9 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) = em.indentLevel = tok.indent elif (em.lastTok in (splitters + oprSet) and tok.tokType notin (closedPars - {tkBracketDotRi})): + if tok.tokType in openPars and tok.indent > em.indentStack[^1]: + while em.indentStack[^1] < tok.indent: + em.indentStack.add(em.indentStack[^1] + em.indWidth) # aka: we are in an expression context: let alignment = max(tok.indent - em.indentStack[^1], 0) em.indentLevel = alignment + em.indentStack.high * em.indWidth |