Skip to content

Commit ab70df3

Browse files
Better patch
1 parent 3c2723a commit ab70df3

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

packages/cursorless-org-docs/src/docs/components/calculateHighlights.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,18 @@ function combineHighlightStyles(range: Range, highlights: Highlight[]): Style {
159159

160160
function getUniquePositions(highlights: Highlight[]): Position[] {
161161
const result: Position[] = [];
162+
const emptyHighlights = highlights.filter((h) => h.range.isEmpty);
162163
const positions = highlights
163164
.flatMap((h) => [h.range.start, h.range.end])
164165
.sort((a, b) =>
165166
a.line === b.line ? a.character - b.character : a.line - b.line,
166167
);
167168
for (let i = 0; i < positions.length; i++) {
168-
if (i === 0 || !positions[i].isEqual(positions[i - 1])) {
169+
if (
170+
i === 0 ||
171+
!positions[i].isEqual(positions[i - 1]) ||
172+
emptyHighlights.some((h) => h.range.start.isEqual(positions[i]))
173+
) {
169174
result.push(positions[i]);
170175
}
171176
}

patches/@shikijs__core.patch

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
diff --git a/dist/index.mjs b/dist/index.mjs
2-
index 5ba9a077425954c8099a26820a3411b017093b0d..28a0d61a7c36c4f796f66fe0ada874b264bc5930 100644
2+
index 5ba9a077425954c8099a26820a3411b017093b0d..6f19e2251ffb3e69abeeadcb16f18399599300c9 100644
33
--- a/dist/index.mjs
44
+++ b/dist/index.mjs
5-
@@ -441,10 +441,10 @@ function verifyIntersections(items) {
6-
throw new ShikiError$1(`Invalid decoration range: ${JSON.stringify(foo.start)} - ${JSON.stringify(foo.end)}`);
7-
for (let j = i + 1; j < items.length; j++) {
8-
const bar = items[j];
9-
- const isFooHasBarStart = foo.start.offset <= bar.start.offset && bar.start.offset < foo.end.offset;
10-
+ const isFooHasBarStart = foo.start.offset <= bar.start.offset && bar.start.offset <= foo.end.offset;
11-
const isFooHasBarEnd = foo.start.offset < bar.end.offset && bar.end.offset <= foo.end.offset;
12-
const isBarHasFooStart = bar.start.offset <= foo.start.offset && foo.start.offset < bar.end.offset;
13-
- const isBarHasFooEnd = bar.start.offset < foo.end.offset && foo.end.offset <= bar.end.offset;
14-
+ const isBarHasFooEnd = bar.start.offset <= foo.end.offset && foo.end.offset <= bar.end.offset;
15-
if (isFooHasBarStart || isFooHasBarEnd || isBarHasFooStart || isBarHasFooEnd) {
16-
if (isFooHasBarStart && isFooHasBarEnd)
5+
@@ -450,6 +450,10 @@ function verifyIntersections(items) {
176
continue;
7+
if (isBarHasFooStart && isBarHasFooEnd)
8+
continue;
9+
+ if (isBarHasFooStart && foo.start.offset === foo.end.offset)
10+
+ continue // leading adjacent empty
11+
+ if (isFooHasBarEnd && bar.start.offset === bar.end.offset)
12+
+ continue // trailing adjacent empty
13+
throw new ShikiError$1(`Decorations ${JSON.stringify(foo.start)} and ${JSON.stringify(bar.start)} intersect.`);
14+
}
15+
}

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)