mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: keep comments after call_expr in vscript (#7990)
This commit is contained in:
parent
561d4f84b3
commit
e79695e8fc
@ -363,6 +363,7 @@ pub mut:
|
||||
free_receiver bool // true if the receiver expression needs to be freed
|
||||
scope &Scope
|
||||
from_embed_type table.Type // holds the type of the embed that the method is called from
|
||||
comments []Comment
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1407,7 +1407,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||
pub fn (mut f Fmt) comments(comments []ast.Comment, options CommentsOptions) {
|
||||
for i, c in comments {
|
||||
if !f.out.last_n(1)[0].is_space() {
|
||||
f.write('\t')
|
||||
f.write(' ')
|
||||
}
|
||||
if options.level == .indent {
|
||||
f.indent++
|
||||
@ -1723,6 +1723,7 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) {
|
||||
f.write(')')
|
||||
f.or_expr(node.or_block)
|
||||
}
|
||||
f.comments(node.comments, has_nl: false)
|
||||
f.use_short_fn_args = old_short_arg_state
|
||||
}
|
||||
|
||||
|
@ -43,4 +43,5 @@ fn main() {
|
||||
//////
|
||||
// /
|
||||
// 123
|
||||
println('hello world')
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/local/bin/v run
|
||||
|
||||
x := 5
|
||||
println(x)
|
||||
println(x) // comment after
|
||||
println('b')
|
||||
// comment between
|
||||
println('c')
|
||||
|
@ -92,6 +92,7 @@ pub fn (mut p Parser) call_expr(language table.Language, mod string) ast.CallExp
|
||||
if fn_name in p.imported_symbols {
|
||||
fn_name = p.imported_symbols[fn_name]
|
||||
}
|
||||
comments := p.eat_line_end_comments()
|
||||
return ast.CallExpr{
|
||||
name: fn_name
|
||||
args: args
|
||||
@ -106,6 +107,7 @@ pub fn (mut p Parser) call_expr(language table.Language, mod string) ast.CallExp
|
||||
pos: or_pos
|
||||
}
|
||||
scope: p.scope
|
||||
comments: comments
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user