Skip to content

Commit 04d537f

Browse files
author
sutong.527608
committed
Improve comment clarity in compareModuleSpecifiersWorker
Rewrite the comment to be more direct and specific about why parameters are reversed: we want absolute imports (isRelative=false) to come before relative imports (isRelative=true).
1 parent cd5f6fc commit 04d537f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/ls/organizeimports.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ func compareModuleSpecifiersWorker(m1, m2 *ast.Expression, comparer func(a, b st
100100
if name1 != "" && name2 != "" {
101101
isRelative1 := tspath.IsExternalModuleNameRelative(name1)
102102
isRelative2 := tspath.IsExternalModuleNameRelative(name2)
103-
// compareBooleans returns -1 if first is true and second is false
104-
// We want relative (true) to come after non-relative (false), so reverse the comparison
103+
// Reverse parameter order because we want absolute imports (isRelative=false) before relative imports (isRelative=true)
105104
if comparison := compareBooleans(isRelative2, isRelative1); comparison != 0 {
106105
return comparison
107106
}

0 commit comments

Comments
 (0)