diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt index 92146d0f5..daff9df41 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt @@ -34,7 +34,7 @@ public interface SelectableColumnOnKeyEvent { state: SelectableLazyListState, ) { val initialIndex = state.lastActiveItemIndex ?: return - val newSelection = LinkedHashSet(max(initialIndex, state.selectedKeys.size)).apply { + val newSelection = HashSet(max(initialIndex, state.selectedKeys.size)).apply { addAll(state.selectedKeys) } var lastActiveItemIndex = initialIndex @@ -75,7 +75,7 @@ public interface SelectableColumnOnKeyEvent { state: SelectableLazyListState, ) { val initialIndex = state.lastActiveItemIndex ?: return - val newSelection = LinkedHashSet(max(keys.size - initialIndex, state.selectedKeys.size)).apply { + val newSelection = HashSet(max(keys.size - initialIndex, state.selectedKeys.size)).apply { addAll(state.selectedKeys) } var lastActiveItemIndex = initialIndex @@ -101,7 +101,7 @@ public interface SelectableColumnOnKeyEvent { for (index in initialIndex - 1 downTo 0) { val key = keys[index] if (key is Selectable) { - state.selectedKeys = linkedSetOf(key.key) + state.selectedKeys = setOf(key.key) state.lastActiveItemIndex = index return } @@ -138,7 +138,7 @@ public interface SelectableColumnOnKeyEvent { for (index in initialIndex + 1..keys.lastIndex) { val key = keys[index] if (key is Selectable) { - state.selectedKeys = linkedSetOf(key.key) + state.selectedKeys = setOf(key.key) state.lastActiveItemIndex = index return } @@ -173,7 +173,7 @@ public interface SelectableColumnOnKeyEvent { ) { val visibleSize = state.layoutInfo.visibleItemsInfo.size val targetIndex = max((state.lastActiveItemIndex ?: 0) - visibleSize, 0) - state.selectedKeys = linkedSetOf(keys[targetIndex].key) + state.selectedKeys = setOf(keys[targetIndex].key) state.lastActiveItemIndex = targetIndex } @@ -240,7 +240,7 @@ public interface SelectableColumnOnKeyEvent { * Select All. */ public fun onSelectAll(keys: List, state: SelectableLazyListState) { - state.selectedKeys = keys.filterIsInstance().map { it.key }.toCollection(LinkedHashSet()) + state.selectedKeys = keys.filterIsInstance().map { it.key }.toCollection(HashSet()) } }