Remove dead empty-members check, extract gapInsertionPoint from insertGap

This commit is contained in:
Ian Gulliver
2026-02-20 17:12:50 -07:00
parent bd3dd1a43d
commit fd0687f2af

View File

@@ -258,9 +258,6 @@ func (tl *Timeline) enforceConstraints() bool {
func (tl *Timeline) enforceExclusives() bool { func (tl *Timeline) enforceExclusives() bool {
for _, g := range tl.exclusives { for _, g := range tl.exclusives {
if len(g.members) == 0 {
continue
}
row := g.members[0].row row := g.members[0].row
allAligned := true allAligned := true
memberTracks := map[*TimelineTrack]bool{} memberTracks := map[*TimelineTrack]bool{}
@@ -313,20 +310,24 @@ func (tl *Timeline) removeGapAt(track *TimelineTrack, index int) {
} }
} }
func (tl *Timeline) insertGap(track *TimelineTrack, beforeIndex int) { func (tl *Timeline) gapInsertionPoint(track *TimelineTrack, index int) int {
for { for {
blocked := false blocked := false
for _, c := range tl.constraints { for _, c := range tl.constraints {
if c.kind == "next_row" && c.a.track == track && c.b.track == track && c.a.row == beforeIndex-1 && c.b.row == beforeIndex { if c.kind == "next_row" && c.a.track == track && c.b.track == track && c.a.row == index-1 && c.b.row == index {
beforeIndex = c.a.row index = c.a.row
blocked = true blocked = true
break break
} }
} }
if !blocked { if !blocked {
break return index
} }
} }
}
func (tl *Timeline) insertGap(track *TimelineTrack, beforeIndex int) {
beforeIndex = tl.gapInsertionPoint(track, beforeIndex)
if tl.isAllGapRow(beforeIndex, track) { if tl.isAllGapRow(beforeIndex, track) {
for _, t := range tl.Tracks { for _, t := range tl.Tracks {