diff options
author | Miran <narimiran@disroot.org> | 2019-07-02 10:52:46 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-07-02 10:52:46 +0200 |
commit | c522a455df3817d98c2cd9132668c4eb9fbb0d88 (patch) | |
tree | df69e37ab6c9300ef01cbba4271d21974a55188e | |
parent | cce8a739da1b74f8d85785524a9b4865afcda3e2 (diff) | |
download | Nim-c522a455df3817d98c2cd9132668c4eb9fbb0d88.tar.gz |
[bugfix] nimpretty indents multiline comments correctly (#11607)
-rw-r--r-- | compiler/layouter.nim | 4 | ||||
-rw-r--r-- | nimpretty/tests/exhaustive.nim | 19 | ||||
-rw-r--r-- | nimpretty/tests/expected/exhaustive.nim | 19 |
3 files changed, 42 insertions, 0 deletions
diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 546d4766e..e45e6400a 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -145,6 +145,10 @@ proc closeEmitter*(em: var Emitter) = maxLhs = 0 lineBegin = i+1 of ltTab: + if i >= 2 and em.kinds[i-2] == ltNewline and em.kinds[i-1] in {ltNewline, ltSpaces}: + # a previous section has ended + maxLhs = 0 + if maxLhs == 0: content.add em.tokens[i] inc lineLen, em.tokens[i].len diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim index ffdc95cca..68d71e7a5 100644 --- a/nimpretty/tests/exhaustive.nim +++ b/nimpretty/tests/exhaustive.nim @@ -657,3 +657,22 @@ type key*, val*: TaintedString ## Key and value pair; the key is the option ## or the argument, and the value is not "" if ## the option was given a value + +block: + var t = 3 + +## This MUST be a multiline comment, +## single line comment would be ok. +block: + var x = 7 + + +block: + var t = 3 + ## another + ## multi + +## This MUST be a multiline comment, +## single line comment would be ok. +block: + var x = 7 diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim index 4d0366afb..4d1b933ef 100644 --- a/nimpretty/tests/expected/exhaustive.nim +++ b/nimpretty/tests/expected/exhaustive.nim @@ -663,3 +663,22 @@ type key*, val*: TaintedString ## Key and value pair; the key is the option ## or the argument, and the value is not "" if ## the option was given a value + +block: + var t = 3 + +## This MUST be a multiline comment, +## single line comment would be ok. +block: + var x = 7 + + +block: + var t = 3 + ## another + ## multi + +## This MUST be a multiline comment, +## single line comment would be ok. +block: + var x = 7 |