1
0
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:
zakuro 2021-01-29 22:48:28 +09:00 committed by GitHub
parent ddcbc4440b
commit f5242890b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -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)
mut imp_alias_suffix := if is_diff { ' as $imp.alias' } else { '' }
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'
}

View File

@ -0,0 +1,5 @@
import math { max, min }
import os {
input,
user_os,
}

View File

@ -0,0 +1,6 @@
import math { max,
min,
}
import os {
input, user_os }