Revert "fix: restore terminal redraw after tab reactivation (#11275)"
Package-Build / Lint (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docs / build (push) Has been cancelled
Package-Build / macOS-Build (arm64, aarch64-apple-darwin) (push) Has been cancelled
Package-Build / macOS-Build (x86_64, x86_64-apple-darwin) (push) Has been cancelled
Package-Build / Linux-Build (amd64, x64, ubuntu-24.04, x86_64-unknown-linux-gnu) (push) Has been cancelled
Package-Build / Linux-Build (arm64, arm64, ubuntu-24.04-arm, aarch64-unknown-linux-gnu, aarch64-linux-gnu-) (push) Has been cancelled
Package-Build / Linux-Build (armhf, arm, ubuntu-24.04, arm-unknown-linux-gnueabihf, arm-linux-gnueabihf-) (push) Has been cancelled
Package-Build / Windows-Build (arm64, aarch64-pc-windows-msvc) (push) Has been cancelled
Package-Build / Windows-Build (x64, x86_64-pc-windows-msvc) (push) Has been cancelled

This reverts commit 5ddcbe303f.
This commit is contained in:
Eugene
2026-06-09 20:58:21 +02:00
parent 1b405ac9af
commit b5fa811137
4 changed files with 15 additions and 72 deletions
@@ -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<P extends BaseTerminalProfile> 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'
})
}
}
})
}
@@ -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)
})
@@ -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()
}
}
+4 -20
View File
@@ -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<string, unknown>).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()