Skip to content

Commit 9933dff

Browse files
committed
Fixes microsoft#86696: Tweak hit testing on Firefox for pseudo elements
1 parent 03d5e98 commit 9933dff

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/vs/editor/browser/controller/mouseTarget.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,23 @@ export class MouseTargetFactory {
925925
}
926926
}
927927

928+
// For inline decorations, Gecko returns the `<span>` of the line and the offset is the `<span>` with the inline decoration
929+
if (hitResult.offsetNode.nodeType === hitResult.offsetNode.ELEMENT_NODE) {
930+
const parent1 = hitResult.offsetNode.parentNode; // expected to be the view line div
931+
const parent1ClassName = parent1 && parent1.nodeType === parent1.ELEMENT_NODE ? (<HTMLElement>parent1).className : null;
932+
933+
if (parent1ClassName === ViewLine.CLASS_NAME) {
934+
const tokenSpan = hitResult.offsetNode.childNodes[Math.min(hitResult.offset, hitResult.offsetNode.childNodes.length - 1)];
935+
if (tokenSpan) {
936+
const p = ctx.getPositionFromDOMInfo(<HTMLElement>tokenSpan, 0);
937+
return {
938+
position: p,
939+
hitTarget: null
940+
};
941+
}
942+
}
943+
}
944+
928945
return {
929946
position: null,
930947
hitTarget: <HTMLElement>hitResult.offsetNode

0 commit comments

Comments
 (0)