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 9baa478985..7e1403e17f 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 @@ -1139,7 +1139,7 @@ fun ChatLayout( if (appPlatform.isDesktop) { val manager = LocalSelectionManager.current val range = manager?.range - if (manager != null && manager.selectionState == SelectionState.Selected && manager.onCopySelection != null && range != null && manager.focusCharRect != Rect.Zero) { + if (manager != null && manager.selectionState == SelectionState.Selected && range != null && manager.focusCharRect != Rect.Zero) { val draggingDown = range.startIndex > range.endIndex || (range.startIndex == range.endIndex && range.startOffset < range.endOffset) val gap = with(LocalDensity.current) { 4.dp.toPx() } var buttonSize by remember { mutableStateOf(IntSize.Zero) } 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 f14cf8d2e1..738a107652 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 @@ -110,7 +110,7 @@ class SelectionManager { val r = range ?: return IntOffset.Zero val ls = listState?.value ?: return IntOffset.Zero val itemInfo = ls.layoutInfo.visibleItemsInfo.find { it.index == r.endIndex } - ?: return IntOffset(0, -10000) + ?: return IntOffset(-10000, -10000) val itemWindowY = (ls.layoutInfo.viewportEndOffset - itemInfo.offset - itemInfo.size).toFloat() val cr = focusCharRect val vp = viewportPosition @@ -145,7 +145,7 @@ fun selectedRange(range: SelectionRange?, index: Int): IntRange? { if (index < lo || index > hi) return null return when { index == r.startIndex && index == r.endIndex -> - if (r.startOffset < 0 || r.endOffset < 0 || r.startOffset == r.endOffset) null + if (r.startOffset < 0 || r.endOffset < 0) null else minOf(r.startOffset, r.endOffset) .. maxOf(r.startOffset, r.endOffset) index == r.startIndex -> if (r.startOffset < 0) null diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TextItemView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TextItemView.kt index 4ab258adc4..2acad27624 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TextItemView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TextItemView.kt @@ -406,7 +406,7 @@ fun ClickableText( val selectionHighlight = if (selectionRange != null) { Modifier.drawBehind { layoutResult.value?.let { result -> - if (selectionRange.first < selectionRange.last && selectionRange.last + 1 <= text.length) { + if (selectionRange.first <= selectionRange.last && selectionRange.last + 1 <= text.length) { drawPath(result.getPathForRange(selectionRange.first, selectionRange.last + 1), SelectionHighlightColor) } } @@ -441,7 +441,7 @@ private fun SelectableText( val highlight = if (selectionRange != null) { Modifier.drawBehind { layoutResult.value?.let { result -> - if (selectionRange.first < selectionRange.last && selectionRange.last + 1 <= text.length) { + if (selectionRange.first <= selectionRange.last && selectionRange.last + 1 <= text.length) { drawPath(result.getPathForRange(selectionRange.first, selectionRange.last + 1), SelectionHighlightColor) } }