vfmt: fix crash when a .v file contains only imports
parent
3aeca70970
commit
7c0a298701
|
@ -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') }
|
// for comment in file.comments { println('$comment.line_nr $comment.text') }
|
||||||
f.imports(f.file.imports) // now that we have all autoimports, handle them
|
f.imports(f.file.imports) // now that we have all autoimports, handle them
|
||||||
res := f.out.str().trim_space() + '\n'
|
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) {
|
pub fn (mut f Fmt) process_file_imports(file &ast.File) {
|
||||||
|
|
Loading…
Reference in New Issue