diff options
| author | Adam <[email protected]> | 2026-02-03 06:34:23 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-02-03 07:03:34 -0600 |
| commit | e88cbefabeba25f90081541fc6e20d403c1bb171 (patch) | |
| tree | 8461751f120d4f17049bd6698bb3dd6881144711 /packages/app/src/addons | |
| parent | a38bae684fec495c4902d45af3af74b777f84abd (diff) | |
| download | opencode-e88cbefabeba25f90081541fc6e20d403c1bb171.tar.gz opencode-e88cbefabeba25f90081541fc6e20d403c1bb171.zip | |
fix(app): terminal serialization bug
Diffstat (limited to 'packages/app/src/addons')
| -rw-r--r-- | packages/app/src/addons/serialize.ts | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/packages/app/src/addons/serialize.ts b/packages/app/src/addons/serialize.ts index 4309a725e..f65788785 100644 --- a/packages/app/src/addons/serialize.ts +++ b/packages/app/src/addons/serialize.ts @@ -442,12 +442,24 @@ class StringSerializeHandler extends BaseSerializeHandler { } } - if (!excludeFinalCursorPosition) { - const absoluteCursorRow = (this._buffer.baseY ?? 0) + this._buffer.cursorY - const cursorRow = constrain(absoluteCursorRow - this._firstRow + 1, 1, Number.MAX_SAFE_INTEGER) - const cursorCol = this._buffer.cursorX + 1 - content += `\u001b[${cursorRow};${cursorCol}H` - } + if (excludeFinalCursorPosition) return content + + const absoluteCursorRow = (this._buffer.baseY ?? 0) + this._buffer.cursorY + const cursorRow = constrain(absoluteCursorRow - this._firstRow + 1, 1, Number.MAX_SAFE_INTEGER) + const cursorCol = this._buffer.cursorX + 1 + content += `\u001b[${cursorRow};${cursorCol}H` + + const line = this._buffer.getLine(absoluteCursorRow) + const cell = line?.getCell(this._buffer.cursorX) + const style = (() => { + if (!cell) return this._buffer.getNullCell() + if (cell.getWidth() !== 0) return cell + if (this._buffer.cursorX > 0) return line?.getCell(this._buffer.cursorX - 1) ?? cell + return cell + })() + + const sgrSeq = this._diffStyle(style, this._cursorStyle) + if (sgrSeq.length) content += `\u001b[${sgrSeq.join(";")}m` return content } |
