Skip to content

Commit

Permalink
fix: lyrics being off by one line (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
mierak authored Dec 14, 2024
1 parent 33027ab commit 69297b3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ui/panes/lyrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ impl Pane for LyricsPane {
let Some(lrc) = &self.current_lyrics else { return Ok(()) };

let elapsed = context.status.elapsed;
let Some((current_line_idx, _)) = lrc
let current_line_idx = lrc
.lines
.iter()
.enumerate()
.filter(|line| line.1.time > elapsed)
.filter(|line| elapsed >= line.1.time)
.min_by(|a, b| a.1.time.abs_diff(elapsed).cmp(&b.1.time.abs_diff(elapsed)))
else {
return Ok(());
};
.map(|result| result.0)
.unwrap_or_default();

let rows = area.height;
let areas = Layout::vertical((0..rows).map(|_| Constraint::Length(1))).split(area);
Expand Down

0 comments on commit 69297b3

Please sign in to comment.