Repository navigation
fix(lyrics): show LRC lines with several timestamps at each one - #834
LargeModGames merged 2 commits into
Conversation
parse_synced_lyrics read only the first [mm:ss.xx] tag, so a line like [00:12.00][00:45.30]Chorus showed once and kept the second tag in its text. Peel every leading timestamp, emit the line once per timestamp, and sort the result so active_lyric_index still sees ascending times. The timestamp math moves into parse_lrc_timestamp unchanged. Fixes LargeModGames#826
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Oud-Idk
left a comment
There was a problem hiding this comment.
Nice PR you got there! Looks clean and no out-of-scope changes. I Really like the direction here.
One minor real-world edge case is a space between the timestamps. Sometimes, hand-crafted or loosely formatted LRC files might have spaces and tabs between tags: [00:12.00] [00:45.30] [01:10.00] Chorus line
With the current parser, rest.strip_prefix('[') breaks on that space, so [00:45.30] leaks into the chorus text.
Adding a .trim_start() directly on the while check would catch those cleanly without complicating the parser logic. As a bonus, it handles leading indentation on the line as well.
|
Thanks for the review, and good catch. Pushed f398254.
One test changed: New tests:
fmt, clippy -D warnings and the full test suite pass with |
Oud-Idk
left a comment
There was a problem hiding this comment.
Great! That's fixed and appreciate the new test coverage.
(Shower thought nit, non-blocking: since the original timestamp parser collects into Vecs twice, we could swap tag.split(':').collect() for split_once to save a couple of allocations. This is possible since we only expect mm:ss or mm:ss.xx)
|
@all-contributors please add @jadhavgaurav for code |
|
I've put up a pull request to add @jadhavgaurav! 🎉 |
Adds @jadhavgaurav as a contributor for code. This was requested by LargeModGames [in this comment](#834 (comment)) [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Fixes #826
What changed
parse_synced_lyricsinsrc/infra/network/utils.rsread only the first[mm:ss.xx]tag on a line and kept the rest as text. A line like[00:12.00][00:45.30]Chorusshowed once at 0:12 with[00:45.30]printed in it, and never at 0:45.parse_lrc_timestamp(tag)helper, so the fraction rules and the rejection of[offset:+500]and[ar:...]are the same as before.[...]groups in a loop, stops at the first group that is not a timestamp, and emits one(ms, text)per timestamp. A line with no leading timestamp still produces nothing.sort_by_key, soactive_lyric_indexgets ascending times and equal timestamps keep file order.CHANGELOG.mdhas a Fixed entry. Nothing else is touched;active_lyric_indexis unchanged.Tests
New tests in the
utils.rstest module: two timestamps on one line (the exact case from the issue), three out-of-order timestamps, unsorted input, same-timestamp stability, empty text with several timestamps, a non-timestamp group staying in the text, malformed tags dropped, and a single-timestamp line unchanged. I ran the new tests against the old parser first and four of them failed (two timestamps, three timestamps, empty text, sorting), then passed after the change.Testing
Run locally on this branch:
cargo fmt --all -- --check: cleancargo clippy --no-default-features --features telemetry,tui -- -D warnings: cleancargo test --no-default-features --features telemetry,tui: 1567 passed, 0 failedcargo test --no-default-features --features telemetry,tui lrc: 14 passed (all 7 existing LRC tests plus the new ones, 1553 filtered out)cargo test --no-default-features --features telemetry,tui parses_timestamped_lyric_lines_and_drops_untimed_ones: 1 passedI did not run the optional manual check in the lyrics view, and did not run the wider CI feature matrix.
AI note: this change was drafted with an AI assistant (Claude Code). I read the full diff and ran the commands above myself.
Summary by CodeRabbit