Skip to content

Commit

Permalink
fmt: fix duplicates remove import comments (#21177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Apr 3, 2024
1 parent 55cafa9 commit f9fa8d8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ pub fn (mut f Fmt) imports(imports []ast.Import) {
imp_stmt := f.imp_stmt_str(imp)
if imp_stmt in processed_imports {
// Skip duplicates.
f.import_comments(imp.next_comments)
continue
}
processed_imports[imp_stmt] = true
Expand Down
1 change: 1 addition & 0 deletions vlib/v/fmt/tests/import_duplicate_expected.vv
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
import os
// keep comment
import gg
import gg { MouseButton }
import time
Expand Down
1 change: 1 addition & 0 deletions vlib/v/fmt/tests/import_duplicate_input.vv
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import math
import os
import math
// keep comment
import gg
import gg { MouseButton }
import time { Duration }
Expand Down

0 comments on commit f9fa8d8

Please sign in to comment.