Fix index & keep split block when editing on TuoDetailDialog
This commit is contained in:
parent
8f3ab1ae80
commit
81515a40f1
2 changed files with 11 additions and 7 deletions
|
|
@ -729,7 +729,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
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)
|
||||
.map { it.value }
|
||||
.filter { it != "." }
|
||||
|
|
@ -756,14 +756,16 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
while (i < allTokens.size) {
|
||||
if (consumedTokenIndices.contains(i)) {
|
||||
val token = allTokens[i]
|
||||
if (token.matches(Regex("[drmfsltDRFSTzw].*|[-―]"))) {
|
||||
val isSplitBlock = token.startsWith("\${") && token.endsWith("}")
|
||||
if (token.matches(Regex("[drmfsltDRFSTzw].*|[-―]")) && !isSplitBlock) {
|
||||
currentLogicalIdx++
|
||||
}
|
||||
i++
|
||||
continue
|
||||
}
|
||||
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) {
|
||||
// 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) {
|
||||
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
|
||||
break
|
||||
}
|
||||
|
|
@ -861,9 +864,10 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
continue
|
||||
}
|
||||
val nextT = allTokens[i]
|
||||
if (!nextT.contains("#") && nextT != "/" && nextT != "(" && nextT != ")") {
|
||||
val nextIsSplit = nextT.startsWith("\${") && nextT.endsWith("}")
|
||||
if (!nextT.contains("#") && nextT != "/" && nextT != "(" && nextT != ")" && !nextIsSplit) {
|
||||
skipped++
|
||||
} else if (hasAnchor) {
|
||||
} else if (hasAnchor || nextIsSplit) {
|
||||
resultTokens.add(nextT)
|
||||
}
|
||||
i++
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,7 @@ fun LazyVerticalGridTUO(
|
|||
selectedIndex = newIndex
|
||||
selectedGridIndex = newIndex
|
||||
val globalList = sharedScreenModel.tuoList.value
|
||||
val nextTUO = globalList.getOrNull(newIndex)
|
||||
val nextTUO = globalList.getOrNull(newIndex+1)
|
||||
|
||||
if (nextTUO != null) {
|
||||
selectedTUO = nextTUO
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue