mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
goto popups: if we can't preserve selection, select most relevant item
This commit is contained in:
@@ -35,9 +35,10 @@ internal data class SelectIndex(private val selectedIndex: Int) : SelectionPolic
|
||||
|
||||
internal object PreserveSelection : SelectionPolicy {
|
||||
override fun performSelection(popup: ChooseByNameBase, model: SmartPointerListModel<Any>): List<Int> {
|
||||
val chosenElements = popup.currentChosenInfo?.chosenElements ?: return emptyList()
|
||||
val chosenElements = popup.currentChosenInfo?.chosenElements.orEmpty()
|
||||
val items = model.items
|
||||
return items.indices.filter { items[it] in chosenElements }
|
||||
val preserved = items.indices.filter { items[it] in chosenElements }
|
||||
return if (preserved.isNotEmpty()) preserved else SelectMostRelevant.performSelection(popup, model)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user