From 45977c2d701fd288782018fa214a4ccedf9de08c Mon Sep 17 00:00:00 2001 From: Clyybber Date: Tue, 20 Oct 2020 01:19:49 +0200 Subject: [PATCH] Fix commentOffsetA for doc comments (#15643) (cherry picked from commit f20e485827df6df97b8396558b10d7c59ca1b7dc) --- compiler/lexer.nim | 2 +- nimpretty/tests/expected/simple.nim | 5 +++++ nimpretty/tests/simple.nim | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 9b1dc642df..c15ecddfcf 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -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) diff --git a/nimpretty/tests/expected/simple.nim b/nimpretty/tests/expected/simple.nim index 5126658ea5..d13558621a 100644 --- a/nimpretty/tests/expected/simple.nim +++ b/nimpretty/tests/expected/simple.nim @@ -11,3 +11,8 @@ proc a() = # comment 2 discard + +# bug #15596 +discard ## comment 3 + +discard # comment 4 diff --git a/nimpretty/tests/simple.nim b/nimpretty/tests/simple.nim index 5126658ea5..435bd6bd2d 100644 --- a/nimpretty/tests/simple.nim +++ b/nimpretty/tests/simple.nim @@ -11,3 +11,8 @@ proc a() = # comment 2 discard + +# bug #15596 +discard## comment 3 + +discard # comment 4