From 12e62aaba1abc205b8ec895a7430109094e60092 Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Tue, 21 Apr 2026 18:05:11 +0000 Subject: [PATCH] desktop: fix select marked deleted when hidden (#6851) --- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 2 +- .../kotlin/chat/simplex/common/views/chat/TextSelection.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 40a89dd8a6..114edeee3d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -2339,7 +2339,7 @@ fun BoxScope.ChatItemsList( } val manager = LocalSelectionManager.current - val modifier = if (appPlatform.isDesktop && manager != null) SelectionHandler(manager, listState, mergedItems, linkMode) else Modifier + val modifier = if (appPlatform.isDesktop && manager != null) SelectionHandler(manager, listState, mergedItems, revealedItems, linkMode) else Modifier LazyColumnWithScrollBar( modifier.align(Alignment.BottomCenter), diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/TextSelection.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/TextSelection.kt index 626aea0806..dee39dde7c 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/TextSelection.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/TextSelection.kt @@ -196,12 +196,13 @@ class SelectionManager { } } - fun getSelectedCopiedText(items: List, linkMode: SimplexLinkMode): String { + fun getSelectedCopiedText(items: List, revealedItems: Set, linkMode: SimplexLinkMode): String { val r = range ?: return "" val lo = minOf(r.startIndex, r.endIndex) val hi = maxOf(r.startIndex, r.endIndex) return (lo..hi).mapNotNull { idx -> val ci = items.getOrNull(idx)?.newest()?.item ?: return@mapNotNull null + if (ci.meta.itemDeleted != null && (!revealedItems.contains(ci.id) || ci.isDeletedContent)) return@mapNotNull null val sel = selectedRange(range, idx) ?: return@mapNotNull null selectedItemCopiedText(ci, sel, linkMode) }.reversed().joinToString("\n") @@ -291,6 +292,7 @@ fun BoxScope.SelectionHandler( manager: SelectionManager, listState: State, mergedItems: State, + revealedItems: State>, linkMode: SimplexLinkMode ): Modifier { val touchSlop = LocalViewConfiguration.current.touchSlop @@ -311,7 +313,7 @@ fun BoxScope.SelectionHandler( manager.listState = listState manager.onCopySelection = { - clipboard.setText(AnnotatedString(manager.getSelectedCopiedText(mergedItems.value.items, linkMode))) + clipboard.setText(AnnotatedString(manager.getSelectedCopiedText(mergedItems.value.items, revealedItems.value, linkMode))) showToast(generalGetString(MR.strings.copied)) }