fix(terminal): fix Clear terminal hotkey action in PowerShell and Clink (#11405)

Co-authored-by: Eugene <inbox@null.page>
This commit is contained in:
KaniPan
2026-09-11 21:58:58 +02:00
committed by GitHub
co-authored by Eugene
parent 9e31ec6dd2
commit 7a44e6bb27
@@ -257,7 +257,18 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
this.frontend?.selectAll()
break
case 'clear':
this.forEachFocusedTerminalPane(tab => tab.frontend?.clear())
this.forEachFocusedTerminalPane(tab => {
const tabProfile = tab.profile
const shellType: string = tabProfile.options?.shellType ?? ''
const shellArgs: string[] = tabProfile.options?.args ?? []
if (this.hostApp.platform === Platform.Windows && (shellType === 'powershell' || shellArgs.some(arg => arg.includes('clink')))) {
// Windows PowerShell and cmd(Clink): send Ctrl+L to PTY (natively clears)
tab.sendInput('\x0c')
} else {
// Windows cmd(stock) and macOS/Linux: clear xterm buffer only
tab.frontend?.clear()
}
})
break
case 'zoom-in':
this.forEachFocusedTerminalPane(tab => tab.zoomIn())