nimpretty: explicit --indent option; fixes #9502; refs #9510 [backport]

This commit is contained in:
Andreas Rumpf 2018-11-11 10:38:41 +01:00
commit d1fe195dcc
4 changed files with 33 additions and 16 deletions

View file

@ -30,7 +30,7 @@ type
lastTok: TTokType
inquote, lastTokWasTerse: bool
semicolons: SemicolonKind
col, lastLineNumber, lineSpan, indentLevel, indWidth: int
col, lastLineNumber, lineSpan, indentLevel, indWidth*: int
keepIndents*: int
doIndentMore*: int
content: string
@ -41,9 +41,10 @@ type
proc openEmitter*(em: var Emitter, cache: IdentCache;
config: ConfigRef, fileIdx: FileIndex) =
let fullPath = Absolutefile config.toFullPath(fileIdx)
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
cache, config)
if em.indWidth == 0: em.indWidth = 2
if em.indWidth == 0:
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
cache, config)
if em.indWidth == 0: em.indWidth = 2
em.config = config
em.fid = fileIdx
em.lastTok = tkInvalid