diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index b585802fc1..b3f39d8b25 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -76,7 +76,8 @@ pub fn fmt(file ast.File, table &table.Table, is_debug bool) string { // for comment in file.comments { println('$comment.line_nr $comment.text') } f.imports(f.file.imports) // now that we have all autoimports, handle them res := f.out.str().trim_space() + '\n' - return res[..f.import_pos] + f.out_imports.str() + res[f.import_pos..] // + '\n' + bounded_import_pos := util.imin(res.len,f.import_pos) + return res[..bounded_import_pos] + f.out_imports.str() + res[bounded_import_pos..] // + '\n' } pub fn (mut f Fmt) process_file_imports(file &ast.File) {