@@ -57,37 +57,40 @@ private static void AppendVoice(StringBuilder sb, Voice voice, bool appendVoiceI
5757 // P1 is optional when only having one voice
5858 sb . AppendLine ( voice . Id . ToString ( ) ) ;
5959 }
60- List < Sentence > sortedSentences = new ( voice . Sentences ) ;
61- sortedSentences . Sort ( Sentence . comparerByStartBeat ) ;
62- foreach ( Sentence sentence in sortedSentences )
60+ List < Sentence > sortedSentences = SongMetaUtils . GetSortedSentences ( voice ) ;
61+ for ( int i = 0 ; i < sortedSentences . Count ; i ++ )
6362 {
64- AppendSentence ( sb , sentence ) ;
63+ Sentence sentence = sortedSentences [ i ] ;
64+ // A linebreak should not be appended after the last sentence.
65+ bool appendLinebreak = i < sortedSentences . Count - 1 ;
66+ AppendSentence ( sb , sentence , appendLinebreak ) ;
6567 }
6668 }
6769
68- private static void AppendSentence ( StringBuilder sb , Sentence sentence )
70+ private static void AppendSentence ( StringBuilder sb , Sentence sentence , bool appendLinebreak )
6971 {
7072 bool isEmpty = sentence . Notes . Count == 0 ;
7173 if ( isEmpty )
7274 {
7375 return ;
7476 }
7577
76- List < Note > sortedNotes = new ( sentence . Notes ) ;
77- sortedNotes . Sort ( Note . comparerByStartBeat ) ;
78+ List < Note > sortedNotes = SongMetaUtils . GetSortedNotes ( sentence ) ;
7879 foreach ( Note note in sortedNotes )
7980 {
8081 AppendNote ( sb , note ) ;
8182 }
82-
83- // TODO: Linebreak timing could be optional but is required by some other tools, https://github.com/UltraStar-Deluxe/format/issues/64
84- sb . AppendLine ( $ "- { sentence . ExtendedMaxBeat } ") ;
85- // if (sentence.ExtendedMaxBeat > sentence.MaxBeat)
86- // {
87- // sb.AppendLine($"- {sentence.ExtendedMaxBeat}");
88- // } else {
89- // sb.AppendLine($"-");
90- // }
83+ if ( appendLinebreak )
84+ {
85+ // TODO: Linebreak timing could be optional but is required by some other tools, https://github.com/UltraStar-Deluxe/format/issues/64
86+ sb . AppendLine ( $ "- { sentence . ExtendedMaxBeat } ") ;
87+ // if (sentence.ExtendedMaxBeat > sentence.MaxBeat)
88+ // {
89+ // sb.AppendLine($"- {sentence.ExtendedMaxBeat}");
90+ // } else {
91+ // sb.AppendLine($"-");
92+ // }
93+ }
9194 }
9295
9396 private static bool IsNotEmpty ( Voice voice )
0 commit comments