Skip to content

Commit 3ba499a

Browse files
committed
Prevent crash when firstChild is not a text node
1 parent 4ff01e6 commit 3ba499a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,13 @@ function shadowCaretRangeFromPoint(shadowRoot: ShadowRoot, x: number, y: number)
11721172
}
11731173

11741174
// Creates a range with the text node of the element and set the offset found
1175-
range.setStart(el.firstChild!, offset);
1176-
range.setEnd(el.firstChild!, offset);
1175+
if (el.firstChild!.nodeType === 3 /* TEXT_NODE */) {
1176+
range.setStart(el.firstChild!, offset);
1177+
range.setEnd(el.firstChild!, offset);
1178+
} else {
1179+
range.setStart(el!, 0);
1180+
range.setEnd(el!, 0);
1181+
}
11771182
}
11781183

11791184
return range;

0 commit comments

Comments
 (0)