fix: terminal garbled glyph + clipped long lines (spawn powershell with -NoProfile, force DECAWM wrap, Cascadia font)

This commit is contained in:
Aisland
2026-08-19 23:28:49 +08:00
parent 10ee100922
commit a4d5646f1d
3 changed files with 18 additions and 3 deletions
+4 -2
View File
@@ -1104,7 +1104,7 @@ function TerminalPane() {
try {
term = new Terminal({
cursorBlink: true,
fontFamily: 'Consolas, Menlo, monospace',
fontFamily: 'Cascadia Code, Cascadia Mono, Consolas, Menlo, monospace',
fontSize: 12,
convertEol: true,
theme: { background: '#010409' },
@@ -1114,6 +1114,8 @@ function TerminalPane() {
return
}
term.open(el)
// 强制自动换行(DECAWM on):超长行在窗口宽度处换行,不被截断
try { term.write('\x1b[?7h') } catch {}
const focusTerm = () => { try { term.focus() } catch {} }
focusTerm()
el.addEventListener('pointerdown', focusTerm)
@@ -1127,7 +1129,7 @@ function TerminalPane() {
setFailed(T('pane.termFail'))
return
}
ws.onopen = () => { focusTerm() }
ws.onopen = () => { focusTerm(); try { term.write('\x1b[?7h') } catch {} }
ws.onmessage = (ev) => { try { term.write(String(ev.data)) } catch {} }
ws.onclose = () => { if (!disposed) { try { term.write('\r\n[连接已关闭]') } catch {} } }
ws.onerror = () => { if (!disposed) setFailed(T('pane.termFail')) }
+1 -1
View File
@@ -151,7 +151,7 @@ function setupTerminal(webServer: any, ctx: any) {
const wss = new WebSocketServer({ noServer: true })
const spawnShell = (): { cmd: string; args: string[] } =>
process.platform === 'win32'
? { cmd: 'powershell.exe', args: ['-NoLogo'] }
? { cmd: 'powershell.exe', args: ['-NoLogo', '-NoProfile'] } // -NoProfile:跳过用户配置(oh-my-posh 花哨提示符在 xterm 里是乱码,PSReadLine 长输入行不换行被截断)
: { cmd: process.env.SHELL || '/bin/bash', args: [] }
const clampDim = (v: number, fallback: number) => Math.min(1024, Math.max(2, Number.isFinite(v) ? v : fallback))