Skip to content

Commit

Permalink
Merge pull request #619 from no-chris/no-chris/issue588
Browse files Browse the repository at this point in the history
Do not repeat chords in copied sections if `autoRepeatChords` is false
  • Loading branch information
no-chris authored Feb 11, 2023
2 parents 87252c6 + bc5acce commit d43e2de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/chord-mark/src/renderer/components/renderSong.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export default function renderSong(

function shouldRepeatLines(line) {
const shouldSkipAutoRepeatChordLine =
line.isFromAutoRepeatChords && !autoRepeatChords;
!autoRepeatChords &&
(line.isFromAutoRepeatChords ||
(line.type === lineTypes.CHORD && line.isFromSectionCopy));

const shouldSkipSectionMultiplyLine =
line.isFromSectionMultiply && !expandSectionMultiply;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,48 @@ verseLine`;
expect(toText(rendered)).toBe(expected);
});

test('should not repeat chords when autoRepeatChords === false', () => {
const input = `#v
A B
verseLine
#v
#v`;
const expected = `Verse 1
|A |B |
verseLine
Verse 2
verseLine
Verse 3
verseLine`;
const rendered = renderSongText(input, {
expandSectionCopy: true,
autoRepeatChords: false,
});
expect(toText(rendered)).toBe(expected);
});

test('should not repeat chords when autoRepeatChords === false, even if the section contains only chords', () => {
const input = `#v
A B
C D
#v
#v`;
const expected = `Verse 1
|A |B |
|C |D |
Verse 2
Verse 3`;
const rendered = renderSongText(input, {
expandSectionCopy: true,
autoRepeatChords: false,
});
expect(toText(rendered)).toBe(expected);
});

test('should only repeat section label when expandSectionCopy === false', () => {
const input = `#v
A B
Expand Down

0 comments on commit d43e2de

Please sign in to comment.