From 5f578bae7981ba9eb09cda6d59437a114c4259eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 18 Dec 2025 12:16:17 +0100 Subject: [PATCH 1/2] fix: fix computed style computation on firefox inside a shadow dom --- src/browser/services/MouseService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser/services/MouseService.ts b/src/browser/services/MouseService.ts index 664d845e28..e9b4e4c72c 100644 --- a/src/browser/services/MouseService.ts +++ b/src/browser/services/MouseService.ts @@ -3,6 +3,7 @@ * @license MIT */ +import { getWindow } from 'vs/base/browser/dom'; import { ICharSizeService, IRenderService, IMouseService } from './Services'; import { getCoords, getCoordsRelativeToElement } from 'browser/input/Mouse'; @@ -30,7 +31,7 @@ export class MouseService implements IMouseService { } public getMouseReportCoords(event: MouseEvent, element: HTMLElement): { col: number, row: number, x: number, y: number } | undefined { - const coords = getCoordsRelativeToElement(window, event, element); + const coords = getCoordsRelativeToElement(getWindow(element), event, element); if (!this._charSizeService.hasValidSize) { return undefined; } From 24b3ac43da4c8f9eb0c1b75fb5ef9d844d9acff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 18 Dec 2025 12:16:32 +0100 Subject: [PATCH 2/2] fix(fit-addon): call getComputedStyle on the right window element --- addons/addon-fit/src/FitAddon.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/addon-fit/src/FitAddon.ts b/addons/addon-fit/src/FitAddon.ts index a282ed3f8c..2cc8485789 100644 --- a/addons/addon-fit/src/FitAddon.ts +++ b/addons/addon-fit/src/FitAddon.ts @@ -23,6 +23,17 @@ interface ITerminalDimensions { const MINIMUM_COLS = 2; const MINIMUM_ROWS = 1; +function getWindow(e: Node): Window { + if (e?.ownerDocument?.defaultView) { + return e.ownerDocument.defaultView.window; + } + + return window; +} +function getComputedStyle(el: HTMLElement): CSSStyleDeclaration { + return getWindow(el).getComputedStyle(el, null); +} + export class FitAddon implements ITerminalAddon , IFitApi { private _terminal: Terminal | undefined; @@ -69,10 +80,10 @@ export class FitAddon implements ITerminalAddon , IFitApi { ? 0 : (this._terminal.options.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH)); - const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement); + const parentElementStyle = getComputedStyle(this._terminal.element.parentElement); const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')); const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width'))); - const elementStyle = window.getComputedStyle(this._terminal.element); + const elementStyle = getComputedStyle(this._terminal.element); const elementPadding = { top: parseInt(elementStyle.getPropertyValue('padding-top')), bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),