mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: keep multiline selective import (#8412)
This commit is contained in:
parent
ddcbc4440b
commit
f5242890b8
@ -262,7 +262,12 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
|||||||
is_diff := imp.alias != imp.mod && !imp.mod.ends_with('.' + imp.alias)
|
is_diff := imp.alias != imp.mod && !imp.mod.ends_with('.' + imp.alias)
|
||||||
mut imp_alias_suffix := if is_diff { ' as $imp.alias' } else { '' }
|
mut imp_alias_suffix := if is_diff { ' as $imp.alias' } else { '' }
|
||||||
if imp.syms.len > 0 {
|
if imp.syms.len > 0 {
|
||||||
imp_alias_suffix += ' { ' + imp.syms.map(it.name).join(', ') + ' }'
|
names := imp.syms.map(it.name)
|
||||||
|
imp_alias_suffix += if imp.syms[0].pos.line_nr == imp.pos.line_nr {
|
||||||
|
' { ' + names.join(', ') + ' }'
|
||||||
|
} else {
|
||||||
|
' {\n\t' + names.join(',\n\t') + ',\n}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return '$imp.mod$imp_alias_suffix'
|
return '$imp.mod$imp_alias_suffix'
|
||||||
}
|
}
|
||||||
|
5
vlib/v/fmt/tests/import_selective_expected.vv
Normal file
5
vlib/v/fmt/tests/import_selective_expected.vv
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import math { max, min }
|
||||||
|
import os {
|
||||||
|
input,
|
||||||
|
user_os,
|
||||||
|
}
|
6
vlib/v/fmt/tests/import_selective_input.vv
Normal file
6
vlib/v/fmt/tests/import_selective_input.vv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import math { max,
|
||||||
|
min,
|
||||||
|
}
|
||||||
|
import os {
|
||||||
|
input, user_os }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user