Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions addons/addon-serialize/src/SerializeAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,16 @@ class StringSerializeHandler extends BaseSerializeHandler {

if (this._nullCellCount > 0) {
// do these because we filled the last several null slot, which we shouldn't
// a move of 0 means a move of 1, so skip the moves when the row has no content
const contentLength = currentLine.length - this._nullCellCount;
rowSeparator += '\u001b[A';
rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}C`;
if (contentLength > 0) {
rowSeparator += `\u001b[${contentLength}C`;
}
rowSeparator += `\u001b[${this._nullCellCount}X`;
rowSeparator += `\u001b[${currentLine.length - this._nullCellCount}D`;
if (contentLength > 0) {
rowSeparator += `\u001b[${contentLength}D`;
}
rowSeparator += '\u001b[B';
}

Expand Down
16 changes: 16 additions & 0 deletions addons/addon-serialize/test/SerializeAddon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,22 @@ test.describe('SerializeAddon', () => {
await testNormalScreenEqual(ctx.page, segments.join(''));
});

test('handle empty row followed by wrapped row', async () => {
const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`;
const MOVE_TO = (row: number, col: number): string => `\u001b[${row};${col}H`;

// The wrap is forced with a row of dashes. With no content in the row, the
// moves around the erase have a count of 0, which means 1.
const segments = [
'abcdefghijXYZ',
MOVE_TO(1, 1),
CLEAR_RIGHT(10),
MOVE_TO(2, 4)
];

await testNormalScreenEqual(ctx.page, segments.join(''));
});

test('handle invalid wrap after scroll', async () => {
const CLEAR_RIGHT = (l: number): string => `\u001b[${l}X`;
const MOVE_UP = (l: number): string => `\u001b[${l}A`;
Expand Down