diff options
author | Araq <rumpf_a@web.de> | 2018-10-24 00:53:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-24 00:53:41 +0200 |
commit | e3a0415650b3b761a2a18907d2f0796c209ba4fa (patch) | |
tree | 79ce0dd6d0a24f2933d6bb0fd50a3a76e974b11c /compiler | |
parent | 72370c8dfab35b46c8aa5f1647d8c7a61b85a68e (diff) | |
download | Nim-e3a0415650b3b761a2a18907d2f0796c209ba4fa.tar.gz |
nimpretty: fixes #9398
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/lexer.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim index c62671ee9..4d08c16b0 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -1118,6 +1118,7 @@ proc skip(L: var TLexer, tok: var TToken) = tok.strongSpaceA = 0 when defined(nimpretty): var hasComment = false + var commentIndent = L.currLineIndent tok.commentOffsetA = L.offsetBase + pos tok.commentOffsetB = tok.commentOffsetA tok.line = -1 @@ -1146,6 +1147,8 @@ proc skip(L: var TLexer, tok: var TToken) = else: break tok.strongSpaceA = 0 + when defined(nimpretty): + if buf[pos] == '#': commentIndent = indent if buf[pos] > ' ' and (buf[pos] != '#' or buf[pos+1] == '#'): tok.indent = indent L.currLineIndent = indent @@ -1155,7 +1158,9 @@ proc skip(L: var TLexer, tok: var TToken) = if buf[pos+1] == '#': break when defined(nimpretty): hasComment = true - if tok.line < 0: tok.line = L.lineNumber + if tok.line < 0: + tok.line = L.lineNumber + #commentIndent = L.currLineIndent # if tok.strongSpaceA == 0: -1 else: tok.strongSpaceA if buf[pos+1] == '[': skipMultiLineComment(L, tok, pos+2, false) @@ -1177,6 +1182,7 @@ proc skip(L: var TLexer, tok: var TToken) = if hasComment: tok.commentOffsetB = L.offsetBase + pos - 1 tok.tokType = tkComment + tok.indent = commentIndent if gIndentationWidth <= 0: gIndentationWidth = tok.indent |