@@ -9,6 +9,8 @@ import type { Position } from "@cursorless/common";
9
9
export function mergeOverlappingDecorations ( decorations : DecorationItem [ ] ) : DecorationItem [ ] {
10
10
if ( decorations . length === 0 ) { return [ ] ; }
11
11
12
+ console . debug ( "[mergeOverlappingDecorations] decorations:" , JSON . stringify ( decorations , null , 2 ) ) ;
13
+
12
14
// Helper to normalize positions (in case shiki uses offset numbers)
13
15
function isPosition ( obj : any ) : obj is Position {
14
16
return obj && typeof obj . line === "number" && typeof obj . character === "number" ;
@@ -25,6 +27,9 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
25
27
)
26
28
) ;
27
29
30
+ console . debug ( "[mergeOverlappingDecorations] zeroWidth:" , JSON . stringify ( zeroWidth , null , 2 ) ) ;
31
+ console . debug ( "[mergeOverlappingDecorations] nonZeroWidth:" , JSON . stringify ( nonZeroWidth , null , 2 ) ) ;
32
+
28
33
// Collect all unique boundary points
29
34
const points : Position [ ] = [ ] ;
30
35
for ( const deco of nonZeroWidth ) {
@@ -96,6 +101,7 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
96
101
startPosToIdx : Map < string , number >
97
102
) : boolean {
98
103
const className = d . properties ?. class ;
104
+ console . debug ( "[handleZeroWidthDecoration] className:" , className , "decoration:" , JSON . stringify ( d , null , 2 ) ) ;
99
105
if ( className === "selection" ) {
100
106
const pos = isPosition ( d . start ) ? `${ d . start . line } :${ d . start . character } ` : String ( d . start ) ;
101
107
const prevIdx = endPosToIdx . get ( pos ) ;
@@ -121,7 +127,11 @@ export function mergeOverlappingDecorations(decorations: DecorationItem[]): Deco
121
127
return true ; // handled
122
128
}
123
129
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
124
133
} else {
134
+ console . error ( "[handleZeroWidthDecoration] Unhandled zero-width decoration class:" , className , d ) ;
125
135
throw new Error ( `Unhandled zero-width decoration class: ${ className } ` ) ;
126
136
}
127
137
}
0 commit comments