Skip to content

Commit

Permalink
fmt: don't break it variable name in match expression function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed May 29, 2024
1 parent 6c9dd62 commit aad0c06
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub mut:
mod2syms map[string]string // import time { now } 'time.now'=>'now'
use_short_fn_args bool
single_line_fields bool // should struct fields be on a single line
it_name string // the name to replace `it` with
in_lambda_depth int
inside_const bool
inside_unsafe bool
Expand Down Expand Up @@ -2258,9 +2257,7 @@ pub fn (mut f Fmt) ident(node ast.Ident) {
}
}
f.write_language_prefix(node.language)
if node.name == 'it' && f.it_name != '' && f.in_lambda_depth == 0 { // allow `it` in lambdas
f.write(f.it_name)
} else if node.kind == .blank_ident {
if node.kind == .blank_ident {
f.write('_')
} else {
mut is_local := false
Expand Down Expand Up @@ -2773,9 +2770,6 @@ fn (mut f Fmt) match_branch(branch ast.MatchBranch, single_line bool) {
pub fn (mut f Fmt) match_expr(node ast.MatchExpr) {
f.write('match ')
f.expr(node.cond)
if node.cond is ast.Ident {
f.it_name = node.cond.name
}
f.writeln(' {')
f.indent++
f.comments(node.comments)
Expand Down Expand Up @@ -2806,7 +2800,6 @@ pub fn (mut f Fmt) match_expr(node ast.MatchExpr) {
}
f.indent--
f.write('}')
f.it_name = ''
}

pub fn (mut f Fmt) offset_of(node ast.OffsetOf) {
Expand Down

0 comments on commit aad0c06

Please sign in to comment.