extract compareTypesForUi

This commit is contained in:
Vladimir Krivosheev
2018-09-06 19:13:22 +02:00
parent 1a22a55029
commit a5dca74808
2 changed files with 7 additions and 2 deletions
@@ -1000,7 +1000,7 @@ open class RunConfigurable @JvmOverloads constructor(private val project: Projec
private fun showAddPopup(showApplicableTypesOnly: Boolean) {
val allTypes = ConfigurationType.CONFIGURATION_TYPE_EP.extensionList
val configurationTypes: MutableList<ConfigurationType?> = getTypesToShow(showApplicableTypesOnly, allTypes).toMutableList()
configurationTypes.sortWith(kotlin.Comparator { type1, type2 -> type1!!.displayName.compareTo(type2!!.displayName, ignoreCase = true) })
configurationTypes.sortWith(kotlin.Comparator { type1, type2 -> compareTypesForUi(type1!!, type2!!) })
val hiddenCount = allTypes.size - configurationTypes.size
if (hiddenCount > 0) {
configurationTypes.add(null)
@@ -3,6 +3,7 @@ package com.intellij.execution.impl
import com.intellij.execution.RunnerAndConfigurationSettings
import com.intellij.execution.compound.CompoundRunConfiguration
import com.intellij.execution.configurations.ConfigurationType
import com.intellij.execution.configurations.RunConfiguration
import com.intellij.openapi.util.text.NaturalComparator
import com.intellij.util.containers.ContainerUtil
@@ -94,7 +95,7 @@ internal class RunConfigurationListManagerHelper(val manager: RunManagerImpl) {
val type1 = o1.type
val type2 = o2.type
if (type1 !== type2) {
return@Comparator NaturalComparator.INSTANCE.compare(type1.displayName, type2.displayName)
return@Comparator compareTypesForUi(type1, type2)
}
val temporary1 = o1.isTemporary
@@ -244,3 +245,7 @@ internal inline fun Collection<RunnerAndConfigurationSettings>.forEachManaged(ha
}
}
}
internal fun compareTypesForUi(type1: ConfigurationType, type2: ConfigurationType): Int {
return NaturalComparator.INSTANCE.compare(type1.displayName, type2.displayName)
}