pass in startLine, endLine, startCol

This commit is contained in:
meganrogge
2025-10-28 11:46:41 -04:00
parent 18bafaf9c9
commit 5a467da137
3 changed files with 15 additions and 7 deletions
@@ -149,17 +149,19 @@ describe('SerializeAddon', () => {
});
it('serializes rows within a provided range', async () => {
await writeP(terminal, 'hello\r\nworld');
await writeP(terminal, 'prompt>hello\r\nworld');
const output = serializeAddon.serializeAsHTML({
range: {
start: 0,
end: 0
startLine: 0,
endLine: 0,
startCol: 7
}
});
const rowMatches = output.match(/<div><span>.*?<\/span><\/div>/g) || [];
assert.equal(rowMatches.length, 1, output);
assert.ok(rowMatches[0]?.includes('hello'));
assert.ok(!output.includes('prompt>'));
assert.ok(!output.includes('world'));
});
+2 -2
View File
@@ -453,8 +453,8 @@ export class SerializeAddon implements ITerminalAddon , ISerializeApi {
const range = options.range;
if (range) {
return handler.serialize({
start: { x: 0, y: typeof range.start === 'number' ? range.start : range.start.line },
end: { x: terminal.cols, y: typeof range.end === 'number' ? range.end : range.end.line }
start: { x: range.startCol, y: typeof range.startLine === 'number' ? range.startLine : range.startLine },
end: { x: terminal.cols, y: typeof range.endLine === 'number' ? range.endLine : range.endLine }
});
}
if (!onlySelection) {
+8 -2
View File
@@ -92,9 +92,15 @@ declare module '@xterm/addon-serialize' {
includeGlobalBackground: boolean;
/**
* The row range to serialize. This is prioritized over {@link onlySelection}.
* The range to serialize. This is prioritized over {@link onlySelection}.
*/
range?: ISerializeRange;
range?: ISerializeBufferRange;
}
export interface ISerializeBufferRange {
startLine: number;
endLine: number;
startCol: number;
}
export interface ISerializeRange {