fix(tmux): handle \r line endings and missing pane_title in list-panes

Strip \r characters from list-panes output to handle Windows-style line
endings. Also relax field count check from 9 to 8 to handle cases where
pane_title is empty or missing, which caused the parser to drop pane
rows and fail to determine the main pane in single-pane sessions.

Fixes #2241
This commit is contained in:
MoerAI
2026-03-04 12:24:22 +09:00
parent 42641a9922
commit e1952d35e6

View File

@@ -27,7 +27,7 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
return null return null
} }
const lines = stdout.trim().split("\n").filter(Boolean) const lines = stdout.trim().replace(/\r/g, "").split("\n").filter(Boolean)
if (lines.length === 0) return null if (lines.length === 0) return null
let windowWidth = 0 let windowWidth = 0
@@ -36,10 +36,10 @@ export async function queryWindowState(sourcePaneId: string): Promise<WindowStat
for (const line of lines) { for (const line of lines) {
const fields = line.split("\t") const fields = line.split("\t")
if (fields.length < 9) continue if (fields.length < 8) continue
const [paneId, widthStr, heightStr, leftStr, topStr, activeStr, windowWidthStr, windowHeightStr] = fields const [paneId, widthStr, heightStr, leftStr, topStr, activeStr, windowWidthStr, windowHeightStr] = fields
const title = fields.slice(8).join("\t") const title = fields.length > 8 ? fields.slice(8).join("\t") : ""
const width = parseInt(widthStr, 10) const width = parseInt(widthStr, 10)
const height = parseInt(heightStr, 10) const height = parseInt(heightStr, 10)
const left = parseInt(leftStr, 10) const left = parseInt(leftStr, 10)