nimpretty: minor bug fix
This commit is contained in:
parent
00f84d3d22
commit
695074214b
3 changed files with 8 additions and 5 deletions
|
|
@ -1120,6 +1120,7 @@ proc skip(L: var TLexer, tok: var TToken) =
|
||||||
var hasComment = false
|
var hasComment = false
|
||||||
tok.commentOffsetA = L.offsetBase + pos
|
tok.commentOffsetA = L.offsetBase + pos
|
||||||
tok.commentOffsetB = tok.commentOffsetA
|
tok.commentOffsetB = tok.commentOffsetA
|
||||||
|
tok.line = -1
|
||||||
while true:
|
while true:
|
||||||
case buf[pos]
|
case buf[pos]
|
||||||
of ' ':
|
of ' ':
|
||||||
|
|
@ -1130,9 +1131,6 @@ proc skip(L: var TLexer, tok: var TToken) =
|
||||||
inc(pos)
|
inc(pos)
|
||||||
of CR, LF:
|
of CR, LF:
|
||||||
tokenEndPrevious(tok, pos)
|
tokenEndPrevious(tok, pos)
|
||||||
when defined(nimpretty):
|
|
||||||
# we are not yet in a comment, so update the comment token's line information:
|
|
||||||
if not hasComment: inc tok.line
|
|
||||||
pos = handleCRLF(L, pos)
|
pos = handleCRLF(L, pos)
|
||||||
buf = L.buf
|
buf = L.buf
|
||||||
var indent = 0
|
var indent = 0
|
||||||
|
|
@ -1155,7 +1153,10 @@ proc skip(L: var TLexer, tok: var TToken) =
|
||||||
of '#':
|
of '#':
|
||||||
# do not skip documentation comment:
|
# do not skip documentation comment:
|
||||||
if buf[pos+1] == '#': break
|
if buf[pos+1] == '#': break
|
||||||
when defined(nimpretty): hasComment = true
|
when defined(nimpretty):
|
||||||
|
hasComment = true
|
||||||
|
if tok.line < 0: tok.line = L.lineNumber
|
||||||
|
|
||||||
if buf[pos+1] == '[':
|
if buf[pos+1] == '[':
|
||||||
skipMultiLineComment(L, tok, pos+2, false)
|
skipMultiLineComment(L, tok, pos+2, false)
|
||||||
pos = L.bufpos
|
pos = L.bufpos
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# comment here
|
||||||
var x: int = 2
|
var x: int = 2
|
||||||
|
|
||||||
echo x
|
echo x
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# comment here
|
||||||
var x: int = 2
|
var x: int = 2
|
||||||
|
|
||||||
echo x
|
echo x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue