Skip to content

Commit

Permalink
Fix commentOffsetA for doc comments (#15643)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clyybber authored Oct 19, 2020
1 parent 0f4b1ed commit f20e485
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/lexer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ proc scanComment(L: var Lexer, tok: var Token) =
tok.iNumber = 0
assert L.buf[pos+1] == '#'
when defined(nimpretty):
tok.commentOffsetA = L.offsetBase + pos - 1
tok.commentOffsetA = L.offsetBase + pos

if L.buf[pos+2] == '[':
skipMultiLineComment(L, tok, pos+3, true)
Expand Down
5 changes: 5 additions & 0 deletions nimpretty/tests/expected/simple.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ proc a() =

# comment 2
discard

# bug #15596
discard ## comment 3

discard # comment 4
5 changes: 5 additions & 0 deletions nimpretty/tests/simple.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ proc a() =

# comment 2
discard

# bug #15596
discard## comment 3

discard # comment 4

0 comments on commit f20e485

Please sign in to comment.