@@ -43,7 +43,7 @@ const emit = defineEmits(["update:selectedMatch", "update:hoveringMatch"]);
43
43
const colors = {
44
44
match: " rgba(60, 115, 168, 0.2)" ,
45
45
matchHovering: " rgba(60, 115, 168, 0.3)" ,
46
- matchSelected: " rgba(26, 188, 156, 0.3 )" ,
46
+ matchSelected: " rgba(26, 188, 156, 0.5 )" ,
47
47
};
48
48
49
49
// File to display
@@ -180,6 +180,15 @@ const initializeSelections = (): void => {
180
180
}
181
181
};
182
182
183
+ const areMatchesEqual = (match1 : Fragment | null , match2 : Fragment | null ) => {
184
+ if (! match1 || ! match2 ) return false ;
185
+
186
+ return match1 .left .startCol === match2 .left .startCol &&
187
+ match1 .left .endCol === match2 .left .endCol &&
188
+ match1 .right .startCol === match2 .right .startCol &&
189
+ match1 .right .endCol === match2 .right .endCol ;
190
+ };
191
+
183
192
// Initialize the editor decorations
184
193
const initializeDecorations = (): void => {
185
194
// Convert the selections into Monaco decorations.
@@ -189,12 +198,13 @@ const initializeDecorations = (): void => {
189
198
const match = selection .match ;
190
199
191
200
let classname = " highlight-match" ;
192
- if (match === selectedMatch .value ) classname += " highlight-match--selected" ;
193
- else if (match === hoveringMatch .value ) classname += " highlight-match--hovering" ;
201
+ if (areMatchesEqual (match , selectedMatch ?.value )) classname += " highlight-match--selected" ;
202
+ else if (areMatchesEqual (match , hoveringMatch ?.value )) classname += " highlight-match--hovering" ;
203
+
194
204
195
205
let color = colors .match ;
196
- if (match === selectedMatch .value ) color = colors .matchSelected ;
197
- else if (match === hoveringMatch .value ) color = colors .matchHovering ;
206
+ if (areMatchesEqual ( match , selectedMatch ? .value ) ) color = colors .matchSelected ;
207
+ else if (areMatchesEqual ( match , hoveringMatch ? .value ) ) color = colors .matchHovering ;
198
208
199
209
return {
200
210
range: selection .range ,
0 commit comments