mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-03 15:46:18 +00:00
fix last character highlight and one-line message selection
This commit is contained in:
@@ -127,14 +127,14 @@ fun highlightedRange(range: SelectionRange?, index: Int): IntRange? {
|
||||
return when {
|
||||
index == r.startIndex && index == r.endIndex ->
|
||||
if (r.startOffset < 0 || r.endOffset < 0 || r.startOffset == r.endOffset) null
|
||||
else minOf(r.startOffset, r.endOffset) until maxOf(r.startOffset, r.endOffset)
|
||||
else minOf(r.startOffset, r.endOffset) .. maxOf(r.startOffset, r.endOffset)
|
||||
index == r.startIndex ->
|
||||
if (r.startOffset < 0) null
|
||||
else if (r.startIndex > r.endIndex) r.startOffset until Int.MAX_VALUE
|
||||
else 0 until r.startOffset
|
||||
else 0 .. r.startOffset
|
||||
index == r.endIndex ->
|
||||
if (r.endOffset < 0) null
|
||||
else if (r.endIndex < r.startIndex) 0 until r.endOffset
|
||||
else if (r.endIndex < r.startIndex) 0 .. r.endOffset
|
||||
else r.endOffset until Int.MAX_VALUE
|
||||
else -> 0 until Int.MAX_VALUE
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ fun MarkdownText (
|
||||
}
|
||||
if (meta != null) withStyle(reserveTimestampStyle) { append(reserve) }
|
||||
}
|
||||
val clampedRange = selectionRange?.let { it.first until minOf(it.last, selectableEnd) }
|
||||
if (clampedRange != null) {
|
||||
val clampedRange = selectionRange?.let { it.first .. minOf(it.last, selectableEnd) }
|
||||
if (onTextLayoutResult != null) {
|
||||
SelectableText(annotatedText, style = style, modifier = modifier, maxLines = maxLines, overflow = overflow, selectionRange = clampedRange, onTextLayoutResult = onTextLayoutResult)
|
||||
} else {
|
||||
Text(annotatedText, style = style, modifier = modifier, maxLines = maxLines, overflow = overflow, inlineContent = inlineContent?.second ?: mapOf())
|
||||
@@ -297,7 +297,7 @@ fun MarkdownText (
|
||||
withStyle(reserveTimestampStyle) { append("\n" + metaText) }
|
||||
else */if (meta != null) withStyle(reserveTimestampStyle) { append(reserve) }
|
||||
}
|
||||
val clampedRange = selectionRange?.let { it.first until minOf(it.last, selectableEnd) }
|
||||
val clampedRange = selectionRange?.let { it.first .. minOf(it.last, selectableEnd) }
|
||||
if ((hasLinks && uriHandler != null) || hasSecrets || (hasCommands && sendCommandMsg != null)) {
|
||||
val icon = remember { mutableStateOf(PointerIcon.Default) }
|
||||
ClickableText(annotatedText, style = style, selectionRange = clampedRange, modifier = modifier.pointerHoverIcon(icon.value), maxLines = maxLines, overflow = overflow,
|
||||
@@ -347,7 +347,7 @@ fun MarkdownText (
|
||||
onTextLayout = { onTextLayoutResult?.invoke(it) }
|
||||
)
|
||||
} else {
|
||||
if (clampedRange != null) {
|
||||
if (onTextLayoutResult != null) {
|
||||
SelectableText(annotatedText, style = style, modifier = modifier, maxLines = maxLines, overflow = overflow, selectionRange = clampedRange, onTextLayoutResult = onTextLayoutResult)
|
||||
} else {
|
||||
Text(annotatedText, style = style, modifier = modifier, maxLines = maxLines, overflow = overflow, inlineContent = inlineContent?.second ?: mapOf())
|
||||
|
||||
Reference in New Issue
Block a user