Merge pull request #178795 from microsoft/hediet/monaco-editor-bugfix

Fixes https://github.com/microsoft/monaco-editor/issues/3217
This commit is contained in:
Henning Dieterichs 2023-03-31 14:34:25 +02:00 committed by GitHub
commit 86dade763c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1033,8 +1033,14 @@ function shadowCaretRangeFromPoint(shadowRoot: ShadowRoot, x: number, y: number)
// Grab its rect
const rect = el.getBoundingClientRect();
// And its font
const font = window.getComputedStyle(el, null).getPropertyValue('font');
// And its font (the computed shorthand font property might be empty, see #3217)
const fontStyle = window.getComputedStyle(el, null).getPropertyValue('font-style');
const fontVariant = window.getComputedStyle(el, null).getPropertyValue('font-variant');
const fontWeight = window.getComputedStyle(el, null).getPropertyValue('font-weight');
const fontSize = window.getComputedStyle(el, null).getPropertyValue('font-size');
const lineHeight = window.getComputedStyle(el, null).getPropertyValue('line-height');
const fontFamily = window.getComputedStyle(el, null).getPropertyValue('font-family');
const font = `${fontStyle} ${fontVariant} ${fontWeight} ${fontSize}/${lineHeight} ${fontFamily}`;
// And also its txt content
const text = (el as any).innerText;