Skip to content

Commit ae15398

Browse files
committed
feat: Allow decorations with class 'full' to pass overlap
1 parent ec4cfc6 commit ae15398

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/test-case-component/src/helpers/decorations/mergeOverlappingDecorations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import type { Position } from "@cursorless/common";
99
export function mergeOverlappingDecorations(decorations: DecorationItem[]): DecorationItem[] {
1010
if (decorations.length === 0) { return []; }
1111

12+
console.debug("[mergeOverlappingDecorations] decorations:", JSON.stringify(decorations, null, 2));
13+
1214
// Helper to normalize positions (in case shiki uses offset numbers)
1315
function isPosition(obj: any): obj is Position {
1416
return obj && typeof obj.line === "number" && typeof obj.character === "number";
@@ -25,6 +27,9 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
2527
)
2628
);
2729

30+
console.debug("[mergeOverlappingDecorations] zeroWidth:", JSON.stringify(zeroWidth, null, 2));
31+
console.debug("[mergeOverlappingDecorations] nonZeroWidth:", JSON.stringify(nonZeroWidth, null, 2));
32+
2833
// Collect all unique boundary points
2934
const points: Position[] = [];
3035
for (const deco of nonZeroWidth) {
@@ -96,6 +101,7 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
96101
startPosToIdx: Map<string, number>
97102
): boolean {
98103
const className = d.properties?.class;
104+
console.debug("[handleZeroWidthDecoration] className:", className, "decoration:", JSON.stringify(d, null, 2));
99105
if (className === "selection") {
100106
const pos = isPosition(d.start) ? `${d.start.line}:${d.start.character}` : String(d.start);
101107
const prevIdx = endPosToIdx.get(pos);
@@ -121,7 +127,11 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
121127
return true; // handled
122128
}
123129
return false; // not handled
130+
} else if (typeof className === "string" && className.includes("full")) {
131+
// Allow decoration classes (e.g., decoration justAdded full) to pass through
132+
return false; // not handled, will be added to filteredZeroWidth
124133
} else {
134+
console.error("[handleZeroWidthDecoration] Unhandled zero-width decoration class:", className, d);
125135
throw new Error(`Unhandled zero-width decoration class: ${className}`);
126136
}
127137
}

0 commit comments

Comments
 (0)