diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 86f97d1603..02e3bc6104 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -367,7 +367,8 @@ pub fn (mut f Fmt) imports(imports []ast.Import) { pub fn (f Fmt) imp_stmt_str(imp ast.Import) string { mod := if imp.mod.len == 0 { imp.alias } else { imp.mod } - is_diff := imp.alias != mod && !mod.ends_with('.' + imp.alias) + normalized_mod := mod.all_after('src.') // Ignore the 'src.' folder prefix since src/ folder is root of code + is_diff := imp.alias != normalized_mod && !normalized_mod.ends_with('.' + imp.alias) mut imp_alias_suffix := if is_diff { ' as ${imp.alias}' } else { '' } mut syms := imp.syms.map(it.name).filter(f.import_syms_used[it]) syms.sort() @@ -378,7 +379,7 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string { ' {\n\t' + syms.join(',\n\t') + ',\n}' } } - return '${mod}${imp_alias_suffix}' + return '${normalized_mod}${imp_alias_suffix}' } //=== Node helpers ===//