goto file: sort files by name-without-extension (IDEA-194877)

This commit is contained in:
peter
2018-07-04 16:28:59 +02:00
parent 62192c8a84
commit 5d072dca21
2 changed files with 8 additions and 0 deletions
@@ -143,6 +143,12 @@ class Intf {
assert gotoFile('i') == [i, index]
}
void "test prefer shorter filename match"() {
def shorter = addEmptyFile("foo/cp-users.txt")
def longer = addEmptyFile("cp-users-and-smth.html")
assert gotoFile('cpusers') == [shorter, longer]
}
void "test consider dot-idea files out of project"() {
def outside = addEmptyFile(".idea/workspace.xml")
def inside = addEmptyFile("workspace.txt")
@@ -163,9 +163,11 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
}
if (group.size() > 1) {
//noinspection StringToUpperCaseOrToLowerCaseWithoutLocale
Collections.sort(group,
Comparator.<PsiFileSystemItem, Boolean>comparing(f -> f instanceof PsiDirectory).
thenComparing(qualifierMatchingDegrees::get).
thenComparing(i -> FileUtilRt.getNameWithoutExtension(i.getName()).toLowerCase()).
thenComparing(i -> i.getName().toLowerCase()).
thenComparing(nesting::get).
thenComparing(dirCloseness::get).