From 3b281334c468492a5d145cfe32c9f1f3e14deb85 Mon Sep 17 00:00:00 2001 From: Luca LeBlanc <67206487+yodaluca23@users.noreply.github.com> Date: Sat, 2 Aug 2025 07:16:20 -0500 Subject: [PATCH] Fix crash when lines are out of order by sorting (#872) --- Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift b/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift index b30e153..702cfd1 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift @@ -29,7 +29,10 @@ struct LyricsDto { ] } else { - lyricsData.lines = lines.map { line in + let sortedLines = lines.sorted { + ($0.offsetMs ?? 0) < ($1.offsetMs ?? 0) + } + lyricsData.lines = sortedLines.map { line in LyricsLine.with { $0.content = (shouldRomanize && romanization == .canBeRomanized) ? line.content.applyingTransform(.toLatin, reverse: false)!