Skip to content

Commit

Permalink
Merge pull request #45 from zostay/fix-random-verse-panic
Browse files Browse the repository at this point in the history
fix: verse subtraction
  • Loading branch information
zostay authored Oct 8, 2024
2 parents f4d57db + fe5c591 commit a4287da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/ref/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (r *Resolved) Subtract(s *Resolved) []Resolved {
return []Resolved{}

// subtracted is at the start of the original, return original without start
case vCmp(r.First, s.First) == 0 && vCmp(r.Last, s.Last) >= 0:
case vCmp(r.First, s.First) >= 0 && vCmp(r.First, s.Last) <= 0 && vCmp(r.Last, s.Last) >= 0:
var firstVerse Verse
for _, v := range r.Verses() {
if s.Last.Before(v) {
Expand All @@ -839,7 +839,7 @@ func (r *Resolved) Subtract(s *Resolved) []Resolved {
}

// subtracted is at the end of the original, return original without end
case vCmp(r.First, s.First) <= 0 && vCmp(r.Last, s.Last) == 0:
case vCmp(r.First, s.First) <= 0 && vCmp(r.Last, s.First) >= 0 && vCmp(r.Last, s.Last) <= 0:
var lastVerse Verse
for _, v := range r.Verses() {
if v.Equal(s.First) {
Expand Down

0 comments on commit a4287da

Please sign in to comment.