@@ -594,7 +594,7 @@ Note* searchTieNote(const Note* note, const Segment* nextSegment, const bool dis
594594 return nullptr ;
595595 }
596596
597- if (disableOverRepeats && !segmentsAreAdjacentInRepeatStructure (seg, nextSegment)) {
597+ if (disableOverRepeats && !segmentsAreAdjacent (seg, nextSegment)) {
598598 return nullptr ;
599599 }
600600
@@ -1596,7 +1596,7 @@ bool repeatHasPartialLyricLine(const Measure* endRepeatMeasure)
15961596 return false ;
15971597}
15981598
1599- bool segmentsAreAdjacentInRepeatStructure (const Segment* firstSeg, const Segment* secondSeg)
1599+ bool segmentsAreAdjacent (const Segment* firstSeg, const Segment* secondSeg)
16001600{
16011601 if (!firstSeg || !secondSeg) {
16021602 return false ;
@@ -1619,12 +1619,20 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment
16191619
16201620 std::vector<const Measure*> measures;
16211621
1622+ bool firstMeasureSegmentFound = false ;
1623+ bool secondMeasureSegmentFound = false ;
1624+
16221625 for (auto it = repeatList.begin (); it != repeatList.end (); it++) {
16231626 const RepeatSegment* rs = *it;
16241627 const auto nextSegIt = std::next (it);
16251628
16261629 // Check if measures are in the same repeat segment
1627- if (rs->containsMeasure (firstMasterMeasure) && rs->containsMeasure (secondMasterMeasure)) {
1630+ bool containsFirstMeasure = rs->containsMeasure (firstMasterMeasure);
1631+ bool containsSecondMeasure = rs->containsMeasure (secondMasterMeasure);
1632+ firstMeasureSegmentFound |= containsFirstMeasure;
1633+ secondMeasureSegmentFound |= containsSecondMeasure;
1634+
1635+ if (containsFirstMeasure && containsSecondMeasure) {
16281636 return true ;
16291637 }
16301638
@@ -1650,6 +1658,11 @@ bool segmentsAreAdjacentInRepeatStructure(const Segment* firstSeg, const Segment
16501658 }
16511659 }
16521660
1661+ if (!firstMeasureSegmentFound && !secondMeasureSegmentFound) {
1662+ // The measures are outside of the (invalid) repeat structure
1663+ return firstMasterMeasure->nextMeasure () == secondMasterMeasure;
1664+ }
1665+
16531666 return false ;
16541667}
16551668
@@ -1881,7 +1894,7 @@ Lyrics* searchNextLyrics(Segment* s, staff_idx_t staffIdx, int verse, PlacementV
18811894 Lyrics* l = nullptr ;
18821895 const Segment* originalSeg = s;
18831896 while ((s = s->next1 (SegmentType::ChordRest))) {
1884- if (!segmentsAreAdjacentInRepeatStructure (originalSeg, s)) {
1897+ if (!segmentsAreAdjacent (originalSeg, s)) {
18851898 return nullptr ;
18861899 }
18871900
0 commit comments