parser, vfmt: multi line comments are not treated as follow-up comments anymore (#9892)

pull/9926/head
Lukas Neubert 2021-04-29 08:48:08 +02:00 committed by GitHub
parent 5152cd4a62
commit b406de20df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,10 @@
import time // foo
/*
block
comment
*/
fn fun() int {
// comment zero
return 0 // another comment

View File

@ -1,3 +1,9 @@
import time // foo
/*
block
comment
*/
fn fun() int {
return /* comment zero */ 0 // another comment
}

View File

@ -642,7 +642,7 @@ pub fn (mut p Parser) eat_comments(cfg EatCommentsConfig) []ast.Comment {
mut comments := []ast.Comment{}
for {
if p.tok.kind != .comment || (cfg.same_line && p.tok.line_nr > line)
|| (cfg.follow_up && p.tok.line_nr > line + 1) {
|| (cfg.follow_up && (p.tok.line_nr > line + 1 || p.tok.lit.contains('\n'))) {
break
}
comments << p.comment()