diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 548bbf91d2cd1..77726e972112b 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -850,6 +850,13 @@ export function getActiveDocument(): Document { return documents.find(doc => doc.hasFocus()) ?? document; } +export function getDocument(element: Node | undefined | null): Document; +export function getDocument(event: UIEvent | undefined | null): Document; +export function getDocument(e: unknown): Document { + const candidateNode = e as Node | undefined | null; + return getWindow(candidateNode).document; +} + export function getActiveWindow(): CodeWindow { const document = getActiveDocument(); return (document.defaultView?.window ?? mainWindow) as CodeWindow; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts index 44271b827be46..f285c0050a6e7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts @@ -20,7 +20,6 @@ import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private' import { IShellLaunchConfig } from 'vs/platform/terminal/common/terminal'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { Disposable } from 'vs/base/common/lifecycle'; -import { $window } from 'vs/base/browser/window'; const enum FontConstants { MinimumFontSize = 6, @@ -119,7 +118,7 @@ export class TerminalConfigHelper extends Disposable implements IBrowserTerminal return rect; } - private _measureFont(fontFamily: string, fontSize: number, letterSpacing: number, lineHeight: number): ITerminalFont { + private _measureFont(w: Window, fontFamily: string, fontSize: number, letterSpacing: number, lineHeight: number): ITerminalFont { const rect = this._getBoundingRectFor('X', fontFamily, fontSize); // Bounding client rect was invalid, use last font measurement if available. @@ -143,10 +142,10 @@ export class TerminalConfigHelper extends Disposable implements IBrowserTerminal if (this.config.gpuAcceleration === 'off') { this._lastFontMeasurement.charWidth = rect.width; } else { - const deviceCharWidth = Math.floor(rect.width * $window.devicePixelRatio); + const deviceCharWidth = Math.floor(rect.width * w.devicePixelRatio); const deviceCellWidth = deviceCharWidth + Math.round(letterSpacing); - const cssCellWidth = deviceCellWidth / $window.devicePixelRatio; - this._lastFontMeasurement.charWidth = cssCellWidth - Math.round(letterSpacing) / $window.devicePixelRatio; + const cssCellWidth = deviceCellWidth / w.devicePixelRatio; + this._lastFontMeasurement.charWidth = cssCellWidth - Math.round(letterSpacing) / w.devicePixelRatio; } } @@ -157,7 +156,7 @@ export class TerminalConfigHelper extends Disposable implements IBrowserTerminal * Gets the font information based on the terminal.integrated.fontFamily * terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties */ - getFont(xtermCore?: IXtermCore, excludeDimensions?: boolean): ITerminalFont { + getFont(w: Window, xtermCore?: IXtermCore, excludeDimensions?: boolean): ITerminalFont { const editorConfig = this._configurationService.getValue('editor'); let fontFamily = this.config.fontFamily || editorConfig.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily; @@ -201,13 +200,13 @@ export class TerminalConfigHelper extends Disposable implements IBrowserTerminal letterSpacing, lineHeight, charHeight: cellDims.height / lineHeight, - charWidth: cellDims.width - Math.round(letterSpacing) / $window.devicePixelRatio + charWidth: cellDims.width - Math.round(letterSpacing) / w.devicePixelRatio }; } } // Fall back to measuring the font ourselves - return this._measureFont(fontFamily, fontSize, letterSpacing, lineHeight); + return this._measureFont(w, fontFamily, fontSize, letterSpacing, lineHeight); } private _clampInt(source: any, minimum: number, maximum: number, fallback: T): number | T { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalGroup.ts b/src/vs/workbench/contrib/terminal/browser/terminalGroup.ts index 5c4b8b19b1f84..65dbfe1b4fc5d 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalGroup.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalGroup.ts @@ -14,6 +14,7 @@ import { ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/comm import { IShellLaunchConfig, ITerminalTabLayoutInfoById, TerminalLocation } from 'vs/platform/terminal/common/terminal'; import { TerminalStatus } from 'vs/workbench/contrib/terminal/browser/terminalStatusList'; import { getPartByLocation } from 'vs/workbench/browser/parts/views/viewsService'; +import { getWindow } from 'vs/base/browser/dom'; const enum Constants { /** @@ -572,7 +573,7 @@ export class TerminalGroup extends Disposable implements ITerminalGroup { } const isHorizontal = (direction === Direction.Left || direction === Direction.Right); - const font = this._terminalService.configHelper.getFont(); + const font = this._terminalService.configHelper.getFont(getWindow(this._groupElement)); // TODO: Support letter spacing and line height const charSize = (isHorizontal ? font.charWidth : font.charHeight); if (charSize) { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 6af540e3357dd..73a905dcd5747 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -637,8 +637,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { return null; } - const font = this.xterm ? this.xterm.getFont() : this._configHelper.getFont(); - const newRC = getXtermScaledDimensions(font, dimension.width, dimension.height); + const font = this.xterm ? this.xterm.getFont() : this._configHelper.getFont(dom.getWindow(this.domElement)); + const newRC = getXtermScaledDimensions(dom.getWindow(this.domElement), font, dimension.width, dimension.height); if (!newRC) { this._setLastKnownColsAndRows(); return null; @@ -667,7 +667,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _getDimension(width: number, height: number): ICanvasDimensions | undefined { // The font needs to have been initialized - const font = this.xterm ? this.xterm.getFont() : this._configHelper.getFont(); + const font = this.xterm ? this.xterm.getFont() : this._configHelper.getFont(dom.getWindow(this.domElement)); if (!font || !font.charWidth || !font.charHeight) { return undefined; } @@ -2031,7 +2031,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } private async _addScrollbar(): Promise { - const charWidth = (this.xterm ? this.xterm.getFont() : this._configHelper.getFont()).charWidth; + const charWidth = (this.xterm ? this.xterm.getFont() : this._configHelper.getFont(dom.getWindow(this.domElement))).charWidth; if (!this.xterm?.raw.element || !this._container || !charWidth || !this._fixedCols) { return; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index 37fe47f99910b..f7b13ecd02cce 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -38,8 +38,7 @@ import Severity from 'vs/base/common/severity'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IEnvironmentVariableCollection, IMergedEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable'; import { generateUuid } from 'vs/base/common/uuid'; -import { $window } from 'vs/base/browser/window'; -import { runWhenWindowIdle } from 'vs/base/browser/dom'; +import { getActiveWindow, runWhenWindowIdle } from 'vs/base/browser/dom'; const enum ProcessConstants { /** @@ -395,7 +394,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce } // Report the latency to the pty host when idle - runWhenWindowIdle($window, () => { + runWhenWindowIdle(getActiveWindow(), () => { this.backend?.getLatency().then(measurements => { this._logService.info(`Latency measurements for ${this.remoteAuthority ?? 'local'} backend\n${measurements.map(e => `${e.label}: ${e.latency.toFixed(2)}ms`).join('\n')}`); }); @@ -749,7 +748,7 @@ class SeamlessRelaunchDataFilter extends Disposable { this.triggerSwap(); } - this._swapTimeout = $window.setTimeout(() => this.triggerSwap(), SeamlessRelaunchConstants.SwapWaitMaximumDuration); + this._swapTimeout = getActiveWindow().setTimeout(() => this.triggerSwap(), SeamlessRelaunchConstants.SwapWaitMaximumDuration); // Pause all outgoing data events this._dataListener?.dispose(); @@ -774,7 +773,7 @@ class SeamlessRelaunchDataFilter extends Disposable { triggerSwap() { // Clear the swap timeout if it exists if (this._swapTimeout) { - $window.clearTimeout(this._swapTimeout); + getActiveWindow().clearTimeout(this._swapTimeout); this._swapTimeout = undefined; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts index 246ad9ec2f27d..4fe3d986ef934 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalStatusList.ts @@ -13,7 +13,7 @@ import { listErrorForeground, listWarningForeground } from 'vs/platform/theme/co import { spinningLoading } from 'vs/platform/theme/common/iconRegistry'; import { ThemeIcon } from 'vs/base/common/themables'; import { ITerminalStatus } from 'vs/workbench/contrib/terminal/common/terminal'; -import { $window } from 'vs/base/browser/window'; +import { getActiveWindow } from 'vs/base/browser/dom'; /** * The set of _internal_ terminal statuses, other components building on the terminal should put @@ -85,11 +85,11 @@ export class TerminalStatusList extends Disposable implements ITerminalStatusLis status = this._applyAnimationSetting(status); const outTimeout = this._statusTimeouts.get(status.id); if (outTimeout) { - $window.clearTimeout(outTimeout); + getActiveWindow().clearTimeout(outTimeout); this._statusTimeouts.delete(status.id); } if (duration && duration > 0) { - const timeout = $window.setTimeout(() => this.remove(status), duration); + const timeout = getActiveWindow().setTimeout(() => this.remove(status), duration); this._statusTimeouts.set(status.id, timeout); } const existingStatus = this._statuses.get(status.id); diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index cf6a056d976a5..767dd15ab7d64 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -45,7 +45,6 @@ import { MouseWheelClassifier } from 'vs/base/browser/ui/scrollbar/scrollableEle import { IMouseWheelEvent, StandardWheelEvent } from 'vs/base/browser/mouseEvent'; import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility'; import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; -import { $window } from 'vs/base/browser/window'; const enum RenderConstants { /** @@ -214,7 +213,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach @ILayoutService layoutService: ILayoutService ) { super(); - const font = this._configHelper.getFont(undefined, true); + const font = this._configHelper.getFont(dom.getActiveWindow(), undefined, true); const config = this._configHelper.config; const editorOptions = this._configurationService.getValue('editor'); @@ -533,7 +532,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach } getFont(): ITerminalFont { - return this._configHelper.getFont(this._core); + return this._configHelper.getFont(dom.getWindow(this.raw.element), this._core); } getLongestViewportWrappedLineLength(): number { @@ -651,9 +650,10 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach e.clipboardData.setData('text/html', textAsHtml); e.preventDefault(); } - $window.document.addEventListener('copy', listener); - $window.document.execCommand('copy'); - $window.document.removeEventListener('copy', listener); + const doc = dom.getDocument(this.raw.element); + doc.addEventListener('copy', listener); + doc.execCommand('copy'); + doc.removeEventListener('copy', listener); } else { await this._clipboardService.writeText(this.raw.getSelection()); } @@ -976,7 +976,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach } } -export function getXtermScaledDimensions(font: ITerminalFont, width: number, height: number) { +export function getXtermScaledDimensions(w: Window, font: ITerminalFont, width: number, height: number) { if (!font.charWidth || !font.charHeight) { return null; } @@ -985,13 +985,13 @@ export function getXtermScaledDimensions(font: ITerminalFont, width: number, hei // the use of canvas, window.devicePixelRatio needs to be used here in // order to be precise. font.charWidth/charHeight alone as insufficient // when window.devicePixelRatio changes. - const scaledWidthAvailable = width * $window.devicePixelRatio; + const scaledWidthAvailable = width * w.devicePixelRatio; - const scaledCharWidth = font.charWidth * $window.devicePixelRatio + font.letterSpacing; + const scaledCharWidth = font.charWidth * w.devicePixelRatio + font.letterSpacing; const cols = Math.max(Math.floor(scaledWidthAvailable / scaledCharWidth), 1); - const scaledHeightAvailable = height * $window.devicePixelRatio; - const scaledCharHeight = Math.ceil(font.charHeight * $window.devicePixelRatio); + const scaledHeightAvailable = height * w.devicePixelRatio; + const scaledCharHeight = Math.ceil(font.charHeight * w.devicePixelRatio); const scaledLineHeight = Math.floor(scaledCharHeight * font.lineHeight); const rows = Math.max(Math.floor(scaledHeightAvailable / scaledLineHeight), 1); diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index dff06787f0e4f..5559fb2ee7e56 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -213,7 +213,7 @@ export interface ITerminalConfigHelper { config: ITerminalConfiguration; configFontIsMonospace(): boolean; - getFont(): ITerminalFont; + getFont(w: any): ITerminalFont; showRecommendations(shellLaunchConfig: IShellLaunchConfig): void; } diff --git a/src/vs/workbench/contrib/terminal/electron-sandbox/terminalNativeContribution.ts b/src/vs/workbench/contrib/terminal/electron-sandbox/terminalNativeContribution.ts index 61bcdaca33f5a..6e953d933d13b 100644 --- a/src/vs/workbench/contrib/terminal/electron-sandbox/terminalNativeContribution.ts +++ b/src/vs/workbench/contrib/terminal/electron-sandbox/terminalNativeContribution.ts @@ -13,8 +13,7 @@ import { INativeHostService } from 'vs/platform/native/common/native'; import { Disposable } from 'vs/base/common/lifecycle'; import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; -import { disposableWindowInterval } from 'vs/base/browser/dom'; -import { $window } from 'vs/base/browser/window'; +import { disposableWindowInterval, getActiveWindow } from 'vs/base/browser/dom'; export class TerminalNativeContribution extends Disposable implements IWorkbenchContribution { declare _serviceBrand: undefined; @@ -63,7 +62,7 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench // Complete when wait marker file is deleted return new Promise(resolve => { let running = false; - const interval = disposableWindowInterval($window, async () => { + const interval = disposableWindowInterval(getActiveWindow(), async () => { if (!running) { running = true; const exists = await this._fileService.exists(path); diff --git a/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts b/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts index 7df51a719410b..331f5a1f55777 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts @@ -11,6 +11,7 @@ import { LinuxDistro } from 'vs/workbench/contrib/terminal/browser/terminal'; import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { mainWindow } from 'vs/base/browser/window'; +import { getActiveWindow } from 'vs/base/browser/dom'; class TestTerminalConfigHelper extends TerminalConfigHelper { set linuxDistro(distro: LinuxDistro) { @@ -42,7 +43,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontFamily, 'bar, monospace', 'terminal.integrated.fontFamily should be selected over editor.fontFamily'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontFamily, 'bar, monospace', 'terminal.integrated.fontFamily should be selected over editor.fontFamily'); }); test('TerminalConfigHelper - getFont fontFamily (Linux Fedora)', () => { @@ -53,7 +54,7 @@ suite('Workbench - TerminalConfigHelper', function () { const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.linuxDistro = LinuxDistro.Fedora; configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set'); }); test('TerminalConfigHelper - getFont fontFamily (Linux Ubuntu)', () => { @@ -64,7 +65,7 @@ suite('Workbench - TerminalConfigHelper', function () { const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.linuxDistro = LinuxDistro.Ubuntu; configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontFamily, '\'Ubuntu Mono\', monospace', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontFamily, '\'Ubuntu Mono\', monospace', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set'); }); test('TerminalConfigHelper - getFont fontFamily (Linux Unknown)', () => { @@ -74,7 +75,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontFamily, 'foo, monospace', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontFamily, 'foo, monospace', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set'); }); test('TerminalConfigHelper - getFont fontSize 10', () => { @@ -92,7 +93,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize'); }); test('TerminalConfigHelper - getFont fontSize 0', () => { @@ -110,11 +111,11 @@ suite('Workbench - TerminalConfigHelper', function () { let configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.linuxDistro = LinuxDistro.Ubuntu; configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it'); configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it'); }); test('TerminalConfigHelper - getFont fontSize 1500', () => { @@ -131,7 +132,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, 100, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, 100, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it'); }); test('TerminalConfigHelper - getFont fontSize null', () => { @@ -149,11 +150,11 @@ suite('Workbench - TerminalConfigHelper', function () { let configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.linuxDistro = LinuxDistro.Ubuntu; configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set'); configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set'); }); test('TerminalConfigHelper - getFont lineHeight 2', () => { @@ -171,7 +172,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight'); }); test('TerminalConfigHelper - getFont lineHeight 0', () => { @@ -189,7 +190,7 @@ suite('Workbench - TerminalConfigHelper', function () { }); const configHelper = store.add(new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!)); configHelper.panelContainer = fixture; - assert.strictEqual(configHelper.getFont().lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set'); + assert.strictEqual(configHelper.getFont(getActiveWindow()).lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set'); }); test('TerminalConfigHelper - isMonospace monospace', () => { diff --git a/src/vs/workbench/contrib/terminalContrib/developer/browser/terminal.developer.contribution.ts b/src/vs/workbench/contrib/terminalContrib/developer/browser/terminal.developer.contribution.ts index c3161cfb897b2..2761345f57205 100644 --- a/src/vs/workbench/contrib/terminalContrib/developer/browser/terminal.developer.contribution.ts +++ b/src/vs/workbench/contrib/terminalContrib/developer/browser/terminal.developer.contribution.ts @@ -24,6 +24,7 @@ import { ITerminalProcessManager, TerminalCommandId } from 'vs/workbench/contrib import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey'; import type { Terminal } from '@xterm/xterm'; import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities'; +import { getWindow } from 'vs/base/browser/dom'; registerTerminalAction({ id: TerminalCommandId.ShowTextureAtlas, @@ -145,7 +146,7 @@ class DevModeContribution extends Disposable implements ITerminalContribution { // Text area syncing if (this._xterm?.raw.textarea) { - const font = this._terminalService.configHelper.getFont(); + const font = this._terminalService.configHelper.getFont(getWindow(this._xterm.raw.textarea)); this._xterm.raw.textarea.style.fontFamily = font.fontFamily; this._xterm.raw.textarea.style.fontSize = `${font.fontSize}px`; } diff --git a/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts b/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts index c8439af52c845..f84ab05bfdd7e 100644 --- a/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts +++ b/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts @@ -1558,7 +1558,7 @@ class TerminalMessagePeek extends Disposable implements IPeekOutputRenderer { ) { width -= 10 + 20; // scrollbar width + margin this.xtermLayoutDelayer.trigger(() => { - const scaled = getXtermScaledDimensions(xterm.getFont(), width, height); + const scaled = getXtermScaledDimensions(dom.getWindow(this.container), xterm.getFont(), width, height); if (scaled) { xterm.resize(scaled.cols, scaled.rows); }