From 3ee53a7c8ed31f41fb0abe0f4f051f5a66559467 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 24 Oct 2018 00:59:57 +0200 Subject: [PATCH] nimpretty: fixes #8078 --- compiler/lexer.nim | 2 +- nimpretty/tests/expected/simple.nim | 8 ++++++++ nimpretty/tests/simple.nim | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 4d08c16b0d..f9fa10a0b3 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -1148,7 +1148,7 @@ proc skip(L: var TLexer, tok: var TToken) = break tok.strongSpaceA = 0 when defined(nimpretty): - if buf[pos] == '#': commentIndent = indent + if buf[pos] == '#' and tok.line < 0: commentIndent = indent if buf[pos] > ' ' and (buf[pos] != '#' or buf[pos+1] == '#'): tok.indent = indent L.currLineIndent = indent diff --git a/nimpretty/tests/expected/simple.nim b/nimpretty/tests/expected/simple.nim index 9e3c52f9bd..5126658ea5 100644 --- a/nimpretty/tests/expected/simple.nim +++ b/nimpretty/tests/expected/simple.nim @@ -3,3 +3,11 @@ var x: int = 2 echo x # bug #9144 + +proc a() = + while true: + discard + # comment 1 + + # comment 2 + discard diff --git a/nimpretty/tests/simple.nim b/nimpretty/tests/simple.nim index 9e3c52f9bd..5126658ea5 100644 --- a/nimpretty/tests/simple.nim +++ b/nimpretty/tests/simple.nim @@ -3,3 +3,11 @@ var x: int = 2 echo x # bug #9144 + +proc a() = + while true: + discard + # comment 1 + + # comment 2 + discard