Fix index & keep split block when editing on TuoDetailDialog

This commit is contained in:
Hasinjato 2026-10-14 09:14:39 +03:00
parent 8f3ab1ae80
commit 81515a40f1
2 changed files with 11 additions and 7 deletions

View file

@ -729,7 +729,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
val cleanNewNote = revertMusicalInput(newNote) val cleanNewNote = revertMusicalInput(newNote)
val regex = Regex("#\\S[',]*|\\s#\\S[',]*|/|\\(|\\)|[drmfsltDRFSTzw][0-9'¹²³⁴⁵₁₂₃₄₅,]*|[-.―•]") val regex = Regex("#\\S[',]*|\\s#\\S[',]*|/|\\(|\\)|\\$\\{[^\\}]+\\}|[drmfsltDRFSTzw][0-9'¹²³⁴⁵₁₂₃₄₅,]*|[-.―•]")
val allTokens = regex.findAll(noteExpanded) val allTokens = regex.findAll(noteExpanded)
.map { it.value } .map { it.value }
.filter { it != "." } .filter { it != "." }
@ -756,14 +756,16 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
while (i < allTokens.size) { while (i < allTokens.size) {
if (consumedTokenIndices.contains(i)) { if (consumedTokenIndices.contains(i)) {
val token = allTokens[i] val token = allTokens[i]
if (token.matches(Regex("[drmfsltDRFSTzw].*|[-―]"))) { val isSplitBlock = token.startsWith("\${") && token.endsWith("}")
if (token.matches(Regex("[drmfsltDRFSTzw].*|[-―]")) && !isSplitBlock) {
currentLogicalIdx++ currentLogicalIdx++
} }
i++ i++
continue continue
} }
val token = allTokens[i] val token = allTokens[i]
val isStructural = token.contains("#") || token == "/" || token == "(" || token == ")" val isSplitBlock = token.startsWith("\${") && token.endsWith("}")
val isStructural = token.contains("#") || token == "/" || token == "(" || token == ")" || isSplitBlock
if (isStructural) { if (isStructural) {
// println(String.format("%-5d | %-10s | %-8s | %-12s | %-10s", i, token, "STRUCT", "-", "Keep")) // println(String.format("%-5d | %-10s | %-8s | %-12s | %-10s", i, token, "STRUCT", "-", "Keep"))
@ -814,7 +816,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
while (lookAheadIdx < allTokens.size) { while (lookAheadIdx < allTokens.size) {
val lat = allTokens[lookAheadIdx] val lat = allTokens[lookAheadIdx]
if ((lat.matches(Regex("[-―]")) || lat.startsWith("z")) && !consumedTokenIndices.contains(lookAheadIdx)) { val latIsSplit = lat.startsWith("\${") && lat.endsWith("}")
if ((lat.matches(Regex("[-―]")) || lat.startsWith("z")) && !consumedTokenIndices.contains(lookAheadIdx) && !latIsSplit) {
foundDashIdx = lookAheadIdx foundDashIdx = lookAheadIdx
break break
} }
@ -861,9 +864,10 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
continue continue
} }
val nextT = allTokens[i] val nextT = allTokens[i]
if (!nextT.contains("#") && nextT != "/" && nextT != "(" && nextT != ")") { val nextIsSplit = nextT.startsWith("\${") && nextT.endsWith("}")
if (!nextT.contains("#") && nextT != "/" && nextT != "(" && nextT != ")" && !nextIsSplit) {
skipped++ skipped++
} else if (hasAnchor) { } else if (hasAnchor || nextIsSplit) {
resultTokens.add(nextT) resultTokens.add(nextT)
} }
i++ i++

View file

@ -1124,7 +1124,7 @@ fun LazyVerticalGridTUO(
selectedIndex = newIndex selectedIndex = newIndex
selectedGridIndex = newIndex selectedGridIndex = newIndex
val globalList = sharedScreenModel.tuoList.value val globalList = sharedScreenModel.tuoList.value
val nextTUO = globalList.getOrNull(newIndex) val nextTUO = globalList.getOrNull(newIndex+1)
if (nextTUO != null) { if (nextTUO != null) {
selectedTUO = nextTUO selectedTUO = nextTUO