mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-29 12:42:57 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d88211636 |
@@ -7,6 +7,20 @@ function cells(text: string): TerminalState["grid"][number] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("renderTerminalSnapshotToAnsi", () => {
|
describe("renderTerminalSnapshotToAnsi", () => {
|
||||||
|
it("preserves adjacent wide characters", () => {
|
||||||
|
const state: TerminalState = {
|
||||||
|
rows: 1,
|
||||||
|
cols: 4,
|
||||||
|
scrollback: [],
|
||||||
|
grid: [[{ char: "\u4e2d" }, { char: "" }, { char: "\u6587" }, { char: "" }]],
|
||||||
|
cursor: { row: 0, col: 4 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const ansi = renderTerminalSnapshotToAnsi(state);
|
||||||
|
|
||||||
|
expect(ansi).toContain("\u4e2d\u6587");
|
||||||
|
});
|
||||||
|
|
||||||
it("renders soft-wrapped rows as one contiguous logical line when wrap flags are present", () => {
|
it("renders soft-wrapped rows as one contiguous logical line when wrap flags are present", () => {
|
||||||
// The server soft-wrapped one logical line "ABCDEFGHIJKLMNOP" at 10 cols into
|
// The server soft-wrapped one logical line "ABCDEFGHIJKLMNOP" at 10 cols into
|
||||||
// two grid rows. gridWrapped[0] = true marks row 0 as continuing into row 1.
|
// two grid rows. gridWrapped[0] = true marks row 0 as continuing into row 1.
|
||||||
|
|||||||
@@ -87,12 +87,15 @@ function renderTerminalRow(row: TerminalCell[], padToCols?: number): string {
|
|||||||
|
|
||||||
for (let index = 0; index < length; index += 1) {
|
for (let index = 0; index < length; index += 1) {
|
||||||
const cell = row[index] ?? { char: " " };
|
const cell = row[index] ?? { char: " " };
|
||||||
|
if (cell.char === "") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const nextStyle = getTerminalStyle(cell);
|
const nextStyle = getTerminalStyle(cell);
|
||||||
if (!terminalStylesEqual(previousStyle, nextStyle)) {
|
if (!terminalStylesEqual(previousStyle, nextStyle)) {
|
||||||
output.push(styleToAnsi(nextStyle));
|
output.push(styleToAnsi(nextStyle));
|
||||||
previousStyle = nextStyle;
|
previousStyle = nextStyle;
|
||||||
}
|
}
|
||||||
output.push(cell.char || " ");
|
output.push(cell.char);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!terminalStylesEqual(previousStyle, DEFAULT_STYLE)) {
|
if (!terminalStylesEqual(previousStyle, DEFAULT_STYLE)) {
|
||||||
|
|||||||
@@ -1626,6 +1626,29 @@ describe("capture", () => {
|
|||||||
expect(capture.totalLines).toBeGreaterThan(0);
|
expect(capture.totalLines).toBeGreaterThan(0);
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
|
test("preserves adjacent CJK characters in captured output", async () => {
|
||||||
|
const cwd = tmpCwd();
|
||||||
|
tempDirs.push(cwd);
|
||||||
|
const created = await createTerminalInWorkspace(ctx.client, { cwd });
|
||||||
|
const terminalId = created.terminal!.id;
|
||||||
|
|
||||||
|
await ctx.client.subscribeTerminal(terminalId);
|
||||||
|
ctx.client.sendTerminalInput(terminalId, {
|
||||||
|
type: "input",
|
||||||
|
data: `node -e "process.stdout.write('START\\u4e2d\\u6587END\\n')"\r`,
|
||||||
|
});
|
||||||
|
await waitForTerminalOutput(
|
||||||
|
ctx.client,
|
||||||
|
terminalId,
|
||||||
|
(text) => text.includes("START\u4e2d\u6587END"),
|
||||||
|
15000,
|
||||||
|
);
|
||||||
|
|
||||||
|
const capture = await ctx.client.captureTerminal(terminalId);
|
||||||
|
|
||||||
|
expect(capture.lines).toContain("START\u4e2d\u6587END");
|
||||||
|
}, 15000);
|
||||||
|
|
||||||
test("captures with start/end line range", async () => {
|
test("captures with start/end line range", async () => {
|
||||||
const cwd = tmpCwd();
|
const cwd = tmpCwd();
|
||||||
tempDirs.push(cwd);
|
tempDirs.push(cwd);
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ function extractCell(terminal: TerminalType, row: number, col: number): Terminal
|
|||||||
const bg = bgMode !== 0 ? cell.getBgColor() : undefined;
|
const bg = bgMode !== 0 ? cell.getBgColor() : undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
char: cell.getChars() || " ",
|
char: cell.getWidth() === 0 ? "" : cell.getChars() || " ",
|
||||||
fg,
|
fg,
|
||||||
bg,
|
bg,
|
||||||
fgMode: fgMode !== 0 ? fgMode : undefined,
|
fgMode: fgMode !== 0 ? fgMode : undefined,
|
||||||
@@ -553,7 +553,7 @@ function extractScrollback(
|
|||||||
const fg = fgMode !== 0 ? cell.getFgColor() : undefined;
|
const fg = fgMode !== 0 ? cell.getFgColor() : undefined;
|
||||||
const bg = bgMode !== 0 ? cell.getBgColor() : undefined;
|
const bg = bgMode !== 0 ? cell.getBgColor() : undefined;
|
||||||
rowCells.push({
|
rowCells.push({
|
||||||
char: cell.getChars() || " ",
|
char: cell.getWidth() === 0 ? "" : cell.getChars() || " ",
|
||||||
fg,
|
fg,
|
||||||
bg,
|
bg,
|
||||||
fgMode: fgMode !== 0 ? fgMode : undefined,
|
fgMode: fgMode !== 0 ? fgMode : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user