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