mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 19:16:40 +02:00
Combine new line limit with previous character checking (use the smallest)
This commit is contained in:
@@ -53,17 +53,18 @@ fun ExpandableRichTextViewer(
|
|||||||
// or after SHORTEN_AFTER_LINES lines
|
// or after SHORTEN_AFTER_LINES lines
|
||||||
val numberOfLines = content.count { it == '\n' }
|
val numberOfLines = content.count { it == '\n' }
|
||||||
|
|
||||||
|
var charactersInLines = minOf(firstSpaceAfterCut, firstNewLineAfterCut)
|
||||||
|
|
||||||
if (numberOfLines > SHORTEN_AFTER_LINES) {
|
if (numberOfLines > SHORTEN_AFTER_LINES) {
|
||||||
val shortContent = content.lines().take(SHORTEN_AFTER_LINES)
|
val shortContent = content.lines().take(SHORTEN_AFTER_LINES)
|
||||||
var charactersInLines = 0
|
charactersInLines = 0
|
||||||
for (line in shortContent) {
|
for (line in shortContent) {
|
||||||
// +1 because new line character is omitted from .lines
|
// +1 because new line character is omitted from .lines
|
||||||
charactersInLines += (line.length + 1)
|
charactersInLines += (line.length + 1)
|
||||||
}
|
}
|
||||||
charactersInLines
|
|
||||||
} else {
|
|
||||||
minOf(firstSpaceAfterCut, firstNewLineAfterCut)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minOf(firstSpaceAfterCut, firstNewLineAfterCut, charactersInLines)
|
||||||
}
|
}
|
||||||
|
|
||||||
val text by remember(content) {
|
val text by remember(content) {
|
||||||
|
Reference in New Issue
Block a user