From 1d9d1a5b811aaf088173d7a96f43f7d209be0027 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sun, 3 Nov 2024 14:36:23 -0500 Subject: [PATCH] Fixed calculation of overlapping (used to check for subset instead) --- matching.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matching.go b/matching.go index e32ff6e..56c6135 100644 --- a/matching.go +++ b/matching.go @@ -6,11 +6,11 @@ type matchIndex struct { endIdx int } -// Returns true if the given matchIndex is an improper subset of any of the indices in the slice. +// Returns true if the given matchIndex has ovelrap with any of the indices in the slice. // When we add an index to our slice, we want to make sure a larger match isn't already present. func overlaps(idx matchIndex, idxes []matchIndex) bool { for _, val := range idxes { - if idx.startIdx >= val.startIdx && idx.endIdx <= val.endIdx { + if (idx.startIdx > val.startIdx && idx.startIdx < val.endIdx) || (idx.endIdx > val.startIdx && idx.endIdx < val.endIdx) { // A zero-length match doesn't overlap if it is located at the start or end // of the other match if !(idx.startIdx == idx.endIdx && (idx.startIdx == val.startIdx || idx.startIdx == val.endIdx)) {