Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not repeat chords in copied sections if autoRepeatChords is false #619

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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