mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-31 21:52:54 +00:00
Keep terminal CJK text unchanged after returning to a workspace (#6452)
* fix(app): restore terminal surface after tab hide so CJK cells redraw Retained panels use display:none. Coming back remasured without treating that as a surface restore, so Hangul kept 2-cell slots while glyphs painted at ~1 cell (extra gap). Reload WebGL if the context was lost and force a refresh when the host grows from zero. Closes #3434 * fix(server): keep wide-char continuation cells out of terminal snapshots Wide chars (CJK) occupy two xterm cells, and the second cell reports no chars. The snapshot capture collapsed that empty continuation to " ", so every restored Hangul syllable took three columns instead of two. The injected space was real: selecting and copying the restored row carried it into the clipboard. Capture the continuation as "" and have renderTerminalSnapshotToAnsi skip it. No schema change; snapshots from older daemons still replay verbatim. * fix(app): restore retained terminals on presentation Co-authored-by: seob717 <dev.seob717@gmail.com> * fix(terminal): limit restoration changes to confirmed CJK corruption Keep the independently reproduced snapshot fix. Surface recovery behavior remains unverified and belongs with the broader viewport report. Dispose the replay terminal after the regression test. --------- Co-authored-by: Jason <mildreins@gmail.com> Co-authored-by: seob717 <dev.seob717@gmail.com> Co-authored-by: liujin0506 <liujin0506@qq.com> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
seob717
Jason
liujin0506
parent
b63a325be3
commit
e81d5d02b1
@@ -47,3 +47,33 @@ describe("renderTerminalSnapshotToAnsi", () => {
|
||||
expect(ansi).toContain("ABCDEFGHIJ\r\nKLMNOP");
|
||||
});
|
||||
});
|
||||
|
||||
describe("renderTerminalSnapshotToAnsi wide chars", () => {
|
||||
it("skips wide-char continuation cells so the glyph keeps its two columns", () => {
|
||||
// The daemon captures "통" as the glyph followed by an empty continuation
|
||||
// cell. Emitting anything for that cell pushes the rest of the row right.
|
||||
const state: TerminalState = {
|
||||
rows: 1,
|
||||
cols: 10,
|
||||
scrollback: [],
|
||||
grid: [[{ char: "통" }, { char: "" }, { char: "합" }, { char: "" }, { char: "!" }]],
|
||||
cursor: { row: 0, col: 5 },
|
||||
};
|
||||
|
||||
expect(renderTerminalSnapshotToAnsi(state)).toContain("통합!");
|
||||
});
|
||||
|
||||
it("replays snapshots from an old daemon verbatim, including its continuation spaces", () => {
|
||||
// Old daemons already collapsed the continuation to " ". The serializer
|
||||
// cannot tell that apart from a real space, so it must not guess.
|
||||
const state: TerminalState = {
|
||||
rows: 1,
|
||||
cols: 10,
|
||||
scrollback: [],
|
||||
grid: [cells("통 합 !")],
|
||||
cursor: { row: 0, col: 6 },
|
||||
};
|
||||
|
||||
expect(renderTerminalSnapshotToAnsi(state)).toContain("통 합 !");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,6 +87,12 @@ function renderTerminalRow(row: TerminalCell[], padToCols?: number): string {
|
||||
|
||||
for (let index = 0; index < length; index += 1) {
|
||||
const cell = row[index] ?? { char: " " };
|
||||
// An empty char marks a wide-char continuation cell. The glyph in the
|
||||
// previous cell already advances the cursor two columns, so emitting
|
||||
// anything here would shift the rest of the row one column right.
|
||||
if (cell.char === "") {
|
||||
continue;
|
||||
}
|
||||
const nextStyle = getTerminalStyle(cell);
|
||||
if (!terminalStylesEqual(previousStyle, nextStyle)) {
|
||||
output.push(styleToAnsi(nextStyle));
|
||||
|
||||
Reference in New Issue
Block a user