mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer shorter names when sorting import candidate list
This commit is contained in:
@@ -138,7 +138,18 @@ class ImportCandidateHolder implements Comparable {
|
||||
|
||||
public int compareTo(Object o) {
|
||||
ImportCandidateHolder rhs = (ImportCandidateHolder) o;
|
||||
return rhs.getRelevance() - getRelevance();
|
||||
int lRelevance = getRelevance();
|
||||
int rRelevance = rhs.getRelevance();
|
||||
if (rRelevance != lRelevance) {
|
||||
return rRelevance - lRelevance;
|
||||
}
|
||||
// prefer shorter paths
|
||||
if (myPath != null && rhs.myPath != null) {
|
||||
int lDots = StringUtil.isEmpty(myPath) ? -1 : StringUtil.countChars(myPath, '.');
|
||||
int rDots = StringUtil.isEmpty(rhs.myPath) ? -1 : StringUtil.countChars(rhs.myPath, '.');
|
||||
return lDots - rDots;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getRelevance() {
|
||||
|
||||
Reference in New Issue
Block a user