Skip to content

Commit

Permalink
fix chordLyric renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
no-chris committed Jan 27, 2024
1 parent f6a3670 commit 17ae381
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
Expand Up @@ -124,15 +124,21 @@ function getAllBreakpoints(allChordTokens, allLyricTokens) {
lyricLineBreakPoints
);

const longestLineBreakpoints =
_last(chordLineBreakPoints) > _last(lyricLineBreakPoints)
? chordLineBreakPoints
: lyricLineBreakPoints;

const lastBreakpoint = _last(allBreakpoints);
const remainingBreakpoints = longestLineBreakpoints.slice(
longestLineBreakpoints.indexOf(lastBreakpoint) + 1
let shortestLineBreakpoints;
let longestLineBreakpoints;

if (_last(chordLineBreakPoints) > _last(lyricLineBreakPoints)) {
longestLineBreakpoints = chordLineBreakPoints;
shortestLineBreakpoints = lyricLineBreakPoints;
} else {
longestLineBreakpoints = lyricLineBreakPoints;
shortestLineBreakpoints = chordLineBreakPoints;
}

const remainingBreakpoints = longestLineBreakpoints.filter(
(bp) => bp > _last(shortestLineBreakpoints)
);

if (remainingBreakpoints.length) {
allBreakpoints.push(...remainingBreakpoints);
}
Expand Down
Expand Up @@ -20,7 +20,6 @@ describe('renderChordLyricLine', () => {
['|', ''],
],
],
/**/
[
'Longer chord line, 2',
'C G',
Expand Down Expand Up @@ -201,6 +200,30 @@ describe('renderChordLyricLine', () => {
['|', ''],
],
],
/**/
[
'Marcia Martienne',
'Bm7 Bm7.. D7/F#..',
'_Voir ma bouche a_vide',
//
//|Bm7 |Bm7.. D7/F#. |
// Voir ma bouche avide
[
['|', ' '],
['Bm7 ', 'Voir'],
[' ', ' '],
[' ', 'ma'],
[' ', ' '],
[' ', 'bouche'],
[' ', ' '],
['|Bm7..', 'avide'],
[' ', ''],
['D7/F#..', ''],
[' ', ''],
['|', ''],
],
{ printChordsDuration: 'always' },
],
/* */
])('%s', (title, chordLine, lyricLine, pairs, options) => {
test(`${chordLine} ${lyricLine}`, () => {
Expand Down

0 comments on commit 17ae381

Please sign in to comment.