Skip to content

Commit

Permalink
Make ChordLine require a chord segment
Browse files Browse the repository at this point in the history
  • Loading branch information
menees committed Feb 11, 2024
1 parent 036d917 commit 8ecac73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Menees.Chords/ChordLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ internal ChordLine(IReadOnlyList<TextSegment> segments, IEnumerable<Entry>? anno

IReadOnlyList<TextSegment> segments = TryGetSegments(context, false, null, out IReadOnlyList<Entry> annotations);

// Make sure there's at least one chord segment, so we avoid degenerate
// cases like "[]", which is a segment of non-letters but not a chord.
ChordLine? result = null;
if (segments.Count > 0)
if (segments.OfType<ChordSegment>().Any())
{
result = new(segments);
result.AddAnnotations(annotations);
Expand Down
1 change: 1 addition & 0 deletions tests/Menees.Chords.Tests/ChordLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void TryParseInvalidTest()
Test("From N.C.");
Test("Am Q7");
Test(" [A12] ");
Test("[]");

static void Test(string text)
{
Expand Down

0 comments on commit 8ecac73

Please sign in to comment.