改行せずに絵文字が12以上並んだら改行を挟む

This commit is contained in:
tateisu 2020-09-10 23:21:01 +09:00
parent 0fc0a95919
commit 2a921ded1a
1 changed files with 13 additions and 12 deletions

View File

@ -52,13 +52,12 @@ class DecodeOptions(
val spans = getSpans(0, length, ReplacementSpan::class.java)
if(spans != null && spans.size >= 40) {
val wrapCount = 12 // if(linkHelper?.isMisskey == true ) 6 else 12
val wrapCount = if(linkHelper?.isMisskey == true) 5 else 12
fun hasLineBreak(start : Int?, end : Int) : Boolean {
if(start != null)
for(i in start until end) {
if(get(i) == '\n') return true
}
fun hasLineBreak(start : Int, end : Int) : Boolean {
for(i in start until end) {
if(get(i) == '\n') return true
}
return false
}
@ -68,12 +67,14 @@ class DecodeOptions(
var preEnd : Int? = null
for(span in spans) {
val start = getSpanStart(span)
val hasLf = hasLineBreak(preEnd, start)
if(hasLf) {
repeatCount = 0
} else if(++ repeatCount >= wrapCount) {
repeatCount = 0
insertList.add(start)
if(preEnd != null) {
val hasLf = hasLineBreak(preEnd, start)
if(hasLf) {
repeatCount = 0
} else if(++ repeatCount >= wrapCount) {
repeatCount = 0
insertList.add(start)
}
}
preEnd = getSpanEnd(span)
}