mirror of
https://github.com/eugeny/tabby
synced 2026-07-08 08:01:17 +00:00
Reapply "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
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 b5fa811137.
This commit is contained in:
@@ -9,6 +9,7 @@ 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'
|
||||
@@ -446,17 +447,7 @@ 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) {
|
||||
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'
|
||||
})
|
||||
}
|
||||
syncTerminalVisibility(this.frontend, visibility)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
export interface VisibilityManagedTerminalFrontend {
|
||||
reactivateAfterVisibilityChange: () => void
|
||||
deactivateAfterVisibilityChange: () => void
|
||||
}
|
||||
|
||||
export function syncTerminalVisibility (frontend: VisibilityManagedTerminalFrontend, visible: boolean): void {
|
||||
if (visible) {
|
||||
frontend.reactivateAfterVisibilityChange()
|
||||
} else {
|
||||
frontend.deactivateAfterVisibilityChange()
|
||||
}
|
||||
}
|
||||
@@ -98,15 +98,20 @@ export class XTermFrontend extends Frontend {
|
||||
this.hostApp = injector.get(HostAppService)
|
||||
this.themes = injector.get(ThemesService)
|
||||
|
||||
this.xterm = new Terminal({
|
||||
const terminalOptions = {
|
||||
allowTransparency: true,
|
||||
allowProposedApi: true,
|
||||
overviewRulerWidth: 8,
|
||||
windowsPty: process.platform === 'win32' ? {
|
||||
backend: this.configService.store.terminal.useConPTY ? 'conpty' : 'winpty',
|
||||
backend: this.configService.store.terminal.useConPTY ? 'conpty' as const : 'winpty' as const,
|
||||
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']
|
||||
|
||||
@@ -360,6 +365,17 @@ 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()
|
||||
|
||||
Reference in New Issue
Block a user