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
15 changes: 15 additions & 0 deletions packages/@wterm/dom/src/__tests__/renderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,20 @@ describe("Renderer", () => {
const span = container.querySelector("span[style]");
expect(span?.getAttribute("style")).toMatch(/font-weight:\s*bold/);
});

it("does not leak the bottom-right cell background to the container", () => {
const grid = [
[makeCell("A", 256, 256), makeCell("B", 256, 2)],
];
const bridge = createMockBridge(2, 1, grid);
const renderer = new Renderer(container);

renderer.render(bridge as any);

expect(container.style.background).toBe("");
expect(container.querySelector(".term-row")?.getAttribute("style")).toContain(
"background",
);
});
});
});
19 changes: 0 additions & 19 deletions packages/@wterm/dom/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export class Renderer {
private rowEls: HTMLDivElement[] = [];
private prevCursorRow = -1;
private prevCursorCol = -1;
private prevContainerBg = "";
private prevRowBg: string[] = [];

private _scrollbackRowEls: HTMLDivElement[] = [];
Expand Down Expand Up @@ -438,24 +437,6 @@ export class Renderer {
this.prevCursorRow = cursor.row;
this.prevCursorCol = cursor.col;

const lastRowDirty = resized || core.isDirtyRow(this.rows - 1);
if (lastRowDirty) {
const bottomRight = core.getCell(this.rows - 1, this.cols - 1);
let gridBgIdx = bottomRight.bg;
let gridBgRgb = bottomRight.bgRgb;
if (bottomRight.flags & FLAG_REVERSE) {
gridBgIdx = bottomRight.fg;
gridBgRgb = bottomRight.fgRgb;
if (gridBgRgb === undefined && gridBgIdx === DEFAULT_COLOR)
gridBgIdx = 7;
}
const containerBg = cellBgCSS(gridBgIdx, gridBgRgb) || "";
if (containerBg !== this.prevContainerBg) {
this.container.style.background = containerBg;
this.prevContainerBg = containerBg;
}
}

core.clearDirty();
}
}
2 changes: 2 additions & 0 deletions packages/@wterm/dom/src/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
.term-grid {
display: block;
white-space: pre;
min-height: 100%;
background: var(--term-bg);
contain: layout paint style;
will-change: contents;
}
Expand Down