diff options
author | Araq <rumpf_a@web.de> | 2018-06-26 01:43:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-06-26 01:43:41 +0200 |
commit | 5976bd96be3d14e033005333d8ddab85b2ee7874 (patch) | |
tree | 735a2483deed2c5a49bcca8dc8dfcee26123f2cb /compiler | |
parent | c68d52b69d479679914aa56fc7b85b25d2baba8b (diff) | |
download | Nim-5976bd96be3d14e033005333d8ddab85b2ee7874.tar.gz |
nimpretty: detect '; vs ,' style based on the first usage of the token in parameter lists
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/layouter.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 62844db4b..36ad08696 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -20,11 +20,15 @@ type SplitKind = enum splitComma, splitParLe, splitAnd, splitOr, splitIn, splitBinary + SemicolonKind = enum + detectSemicolonKind, useSemicolon, dontTouch + Emitter* = object config: ConfigRef fid: FileIndex lastTok: TTokType inquote: bool + semicolons: SemicolonKind col, lastLineNumber, lineSpan, indentLevel, indWidth: int nested: int doIndentMore*: int @@ -258,7 +262,9 @@ proc starWasExportMarker*(em: var Emitter) = dec em.col, 2 proc commaWasSemicolon*(em: var Emitter) = - if em.content.endsWith(", "): + if em.semicolons == detectSemicolonKind: + em.semicolons = if em.content.endsWith(", "): dontTouch else: useSemicolon + if em.semicolons == useSemicolon and em.content.endsWith(", "): setLen(em.content, em.content.len-2) em.content.add("; ") |