aziznal / dart-import-sorter

A vscode extension that groups and sorts imports for dart files (https://marketplace.visualstudio.com/items?itemName=aziznal.dart-import-sorter)
MIT License
14 stars 1 forks source link

Fix duplicating issue when running sort on one import statement #54

Closed aziznal closed 1 year ago

aziznal commented 1 year ago

Description

Sorting when only a single import statement is detected would cause that statement to be duplicated. This is due to how the line number for import statements is calculated.

This PR fixes that.


Previously:

// this is an import
import 'something.dart';

would become this after sorting:

// this is an import
import 'something.dart';
import 'something.dart';    // <- Duplicated!

Now:

Sorting doesn't even run when only one import statement is detected.

Solves #53