Skip to content

Commit

Permalink
Fix raw SVP parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sdercolin committed Feb 11, 2024
1 parent 1f78420 commit b4b0cb1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/jsMain/kotlin/io/Svp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import kotlin.math.roundToLong

object Svp {
suspend fun parse(file: File, params: ImportParams): model.Project {
val text = file.readText().let {
val index = it.lastIndexOf('}')
it.take(index + 1)
}
val project = jsonSerializer.decodeFromString(Project.serializer(), text)
val rawProjects = file.readText().split("\u0000")
.map { it.trim('\u0000') }
.filter { it.isNotBlank() }
val projects = rawProjects.map { jsonSerializer.decodeFromString(Project.serializer(), it) }
val project = projects.maxBy { it.version ?: 0 }
val warnings = mutableListOf<ImportWarning>()
val timeSignatures = project.time.meter?.map {
TimeSignature(
Expand Down

0 comments on commit b4b0cb1

Please sign in to comment.