Skip to content

Fix extra end of phrase after the last note#576

Merged
achimmihca merged 4 commits into
UltraStar-Deluxe:masterfrom
Tuupertunut:fix/extra-end-of-phrase
May 20, 2026
Merged

Fix extra end of phrase after the last note#576
achimmihca merged 4 commits into
UltraStar-Deluxe:masterfrom
Tuupertunut:fix/extra-end-of-phrase

Conversation

@Tuupertunut
Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes the issue where the editor saved song files with an additional end-of-phrase marker after the last note, as described in #573.

Closes Issue(s)

#573

Additional Notes

There is a wiki page with an example song file with extra end-of-phrase markers that needs to be updated if this gets merged.
https://github.com/UltraStar-Deluxe/Play/wiki/UltraStar-txt-File-Format

The UltraStar format specification v1 says that there should not be a trailing end-of-phrase marker after the last sentence.
foreach (Sentence sentence in sortedSentences.SkipLast(1))
{
AppendSentence(sb, sentence);
AppendSentence(sb, sentence, true);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer setting the flag based on "is this the last sentence".
Consider to iterate by index, then check if index matches (sentences length - 1).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like

for all sentences
{
    AppendSentence(... , (i == last))
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored that loop to check index.

@achimmihca
Copy link
Copy Markdown
Collaborator

achimmihca commented Apr 21, 2026

Please add a Edit Mode test for this. See Assets/Editor/Tests.
The Edit Mode tests are simple unit tests, much simplier than the Play Mode test.

@achimmihca
Copy link
Copy Markdown
Collaborator

There is a wiki page with an example song file with extra end-of-phrase markers that needs to be updated if this gets merged.

I sent you an invitation to the repo with WRITE access. You should now be able to edit the wiki pages.
Can edit the wiki in browser, or via its repo: https://github.com/UltraStar-Deluxe/Play.wiki.git

@Tuupertunut
Copy link
Copy Markdown
Collaborator Author

I added an edit mode test for this fix.

@achimmihca achimmihca merged commit b4ca30c into UltraStar-Deluxe:master May 20, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants