summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/lexer.nim2
-rw-r--r--nimpretty/tests/expected/simple.nim8
-rw-r--r--nimpretty/tests/simple.nim8
3 files changed, 17 insertions, 1 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 4d08c16b0..f9fa10a0b 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 9e3c52f9b..5126658ea 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 9e3c52f9b..5126658ea 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