diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index 04438017..e2454259 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -9,7 +9,6 @@ import { BaseSession } from '../session' import { Frontend } from '../frontends/frontend' import { XTermFrontend, XTermWebGLFrontend } from '../frontends/xtermFrontend' -import { syncTerminalVisibility } from '../frontends/visibility' import { ResizeEvent, BaseTerminalProfile } from './interfaces' import { TerminalDecorator } from './decorator' import { SearchPanelComponent } from '../components/searchPanel.component' @@ -447,7 +446,17 @@ export class BaseTerminalTabComponent

extends Bas .pipe(debounce(visibility => interval(visibility ? 0 : INACTIVE_TAB_UNLOAD_DELAY))) .subscribe(visibility => { if (this.frontend instanceof XTermFrontend) { - syncTerminalVisibility(this.frontend, visibility) + if (visibility) { + // this.frontend.resizeHandler() + const term = this.frontend.xterm as any + term._core._renderService?.clear() + term._core._renderService?.handleResize(term.cols, term.rows) + } else { + this.frontend.xterm.element?.querySelectorAll('canvas').forEach(c => { + c.height = c.width = 0 + c.style.height = c.style.width = '0px' + }) + } } }) } diff --git a/tabby-terminal/src/frontends/visibility.test.js b/tabby-terminal/src/frontends/visibility.test.js deleted file mode 100644 index de564117..00000000 --- a/tabby-terminal/src/frontends/visibility.test.js +++ /dev/null @@ -1,38 +0,0 @@ -import assert from 'node:assert/strict' -import test from 'node:test' - -import { syncTerminalVisibility } from './visibility.ts' - -test('syncTerminalVisibility reactivates the frontend when the tab becomes visible', () => { - let reactivated = 0 - let deactivated = 0 - - syncTerminalVisibility({ - reactivateAfterVisibilityChange: () => { - reactivated++ - }, - deactivateAfterVisibilityChange: () => { - deactivated++ - }, - }, true) - - assert.equal(reactivated, 1) - assert.equal(deactivated, 0) -}) - -test('syncTerminalVisibility releases hidden-tab resources when the tab becomes invisible', () => { - let reactivated = 0 - let deactivated = 0 - - syncTerminalVisibility({ - reactivateAfterVisibilityChange: () => { - reactivated++ - }, - deactivateAfterVisibilityChange: () => { - deactivated++ - }, - }, false) - - assert.equal(reactivated, 0) - assert.equal(deactivated, 1) -}) diff --git a/tabby-terminal/src/frontends/visibility.ts b/tabby-terminal/src/frontends/visibility.ts deleted file mode 100644 index 7302e765..00000000 --- a/tabby-terminal/src/frontends/visibility.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface VisibilityManagedTerminalFrontend { - reactivateAfterVisibilityChange: () => void - deactivateAfterVisibilityChange: () => void -} - -export function syncTerminalVisibility (frontend: VisibilityManagedTerminalFrontend, visible: boolean): void { - if (visible) { - frontend.reactivateAfterVisibilityChange() - } else { - frontend.deactivateAfterVisibilityChange() - } -} diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index f34a10e2..d2adbcf8 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -98,20 +98,15 @@ export class XTermFrontend extends Frontend { this.hostApp = injector.get(HostAppService) this.themes = injector.get(ThemesService) - const terminalOptions = { + this.xterm = new Terminal({ allowTransparency: true, allowProposedApi: true, + overviewRulerWidth: 8, windowsPty: process.platform === 'win32' ? { - backend: this.configService.store.terminal.useConPTY ? 'conpty' as const : 'winpty' as const, + backend: this.configService.store.terminal.useConPTY ? 'conpty' : 'winpty', buildNumber: getWindows10Build(), } : undefined, - } - ;(terminalOptions as Record).overviewRuler = { - width: 8, - showBottomBorder: false, - showTopBorder: false, - } - this.xterm = new Terminal(terminalOptions) + }) this.flowControl = new FlowControl(this.xterm) this.xtermCore = this.xterm['_core'] @@ -365,17 +360,6 @@ export class XTermFrontend extends Frontend { delete this.resizeObserver } - reactivateAfterVisibilityChange (): void { - this.resizeHandler() - } - - deactivateAfterVisibilityChange (): void { - this.xterm.element?.querySelectorAll('canvas').forEach(c => { - c.height = c.width = 0 - c.style.height = c.style.width = '0px' - }) - } - destroy (): void { super.destroy() this.webGLAddon?.dispose()