Skip to content

Arrangement.Parse rejects a chart whose sections are separated by two blank lines or by a whitespace-only line #339

Closed

Description

@matt-edmondson

What's wrong

Arrangement.TryParse (Semantics.Music/Arrangement.cs:96) splits the text on exactly "\n\n". It then passes each block to Section.TryParse without trimming it. Section.TryParse requires the block's first character to be [ (Section.cs:116-118). Two layouts break this:

  • Three newlines between sections. The next block starts with "\n", so it fails the [ check.
  • A blank line holding a space or tab ("\n \n"). The split never happens, so two sections are read as one block.

Either way the whole parse fails.

Reproduced against HEAD 9c64b67, starting from a valid arrangement a with a Verse and a Chorus:

  • Arrangement.Parse(a.ToString()) round-trips. CRLF input is also fine.
  • Arrangement.Parse(a.ToString().Replace("\n\n", "\n\n\n")) throws FormatException.
  • Arrangement.Parse(a.ToString().Replace("\n\n", "\n \n")) throws FormatException.

Why it matters

Arrangements are hand-written chart files. An extra blank line between sections, or an editor leaving trailing whitespace on the separator line, makes a valid chart unparseable. The error doesn't point at the cause.

Suggested fix

Split into lines and treat any run of empty or whitespace-only lines as one section separator. Alternatively, trim leading and trailing newlines from each block and drop blocks that are empty after trimming.

Acceptance criteria

  • Both variants above parse equal to a.
  • The existing arrangement round-trip tests still pass.

Activity

  1. matt-edmondson commented on Sep 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug
    • Priority: Medium. Hand-written charts with an extra blank line, or trailing whitespace on the separator line, fail to parse, and the error doesn't point at the cause. Nothing is lost silently, and the fix is local.
    • Area: Semantics.Music/Arrangement.cs:96 (section split) and Section.TryParse.
    • Suggested assignment: Semantics.Music maintainer.
    • Duplicates / in progress: None found. The open PRs (Bump the ktsu group with 15 updates #323, Bump MSTest.Sdk from 4.4.0 to 4.4.1 #255) are dependency bumps.

    Generated by Claude Code

  2. matt-edmondson commented on Oct 29, 2026

    @matt-edmondson
    ContributorAuthor

    Fixed by #487 (commit 47dffbb, now on main). The commit cites this issue inline as "(#339)" rather than with a "Fixes" keyword, so GitHub didn't close it. Closing by hand.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions