Skip to content

Commit 8440a37

Browse files
Handle overlapping ranges
1 parent e463bc1 commit 8440a37

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/cursorless-org-docs/src/docs/user/languages/components/ScopeVisualizer.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,7 @@ function renderFixture(
7171
rangeType === "content"
7272
? scope.content
7373
: (scope.removal ?? scope.content);
74-
const range = Range.fromConcise(conciseRange);
75-
76-
// TODO: fix overlapping ranges
77-
if (previousRange != null && previousRange.intersection(range) != null) {
78-
// If the previous range intersects with the current range, we skip
79-
// highlighting the current range to avoid overlapping highlights
80-
break;
81-
}
74+
let range = Range.fromConcise(conciseRange);
8275

8376
if (scope.domain != null && scope.domain !== conciseRange) {
8477
highlights.push({
@@ -87,6 +80,19 @@ function renderFixture(
8780
});
8881
}
8982

83+
if (previousRange != null) {
84+
const intersection = previousRange.intersection(range);
85+
86+
if (intersection != null && !intersection.isEmpty) {
87+
highlights.push({
88+
type: rangeType,
89+
range: intersection,
90+
});
91+
92+
range = new Range(intersection.end, range.end);
93+
}
94+
}
95+
9096
highlights.push({
9197
type: rangeType,
9298
range,

0 commit comments

Comments
 (0)