Skip to content

Commit 932bcf6

Browse files
authored
fix(test): work around a node 26.4 crash (#1265)
1 parent cdd15e6 commit 932bcf6

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

packages/core/src/renderables/__tests__/Textarea.scroll.test.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ let clock: ManualClock
1212

1313
const simulateFrames = (ms: number, frameInterval?: number) => _simulateFrames(clock, renderOnce, ms, frameInterval)
1414

15+
function countSelectedCells(
16+
background: Uint16Array,
17+
bufferWidth: number,
18+
bounds: { x: number; y: number; width: number; height: number },
19+
): number {
20+
let selectedCells = 0
21+
for (let y = bounds.y; y < bounds.y + bounds.height; y++) {
22+
for (let x = bounds.x; x < bounds.x + bounds.width; x++) {
23+
const bufferIdx = y * bufferWidth + x
24+
const bgG = (background[bufferIdx * 4 + 1] & 0xff) / 255
25+
if (Math.abs(bgG - 1.0) < 0.01) {
26+
selectedCells++
27+
}
28+
}
29+
}
30+
return selectedCells
31+
}
32+
1533
describe("Textarea - Scroll Tests", () => {
1634
beforeEach(async () => {
1735
clock = new ManualClock()
@@ -700,22 +718,12 @@ describe("Textarea - Scroll Tests", () => {
700718
expect(frames.length).toBeGreaterThan(10)
701719

702720
const bufferWidth = currentRenderer.width
721+
const editorBounds = { x: editor.x, y: editor.y, width: editor.width, height: editor.height }
703722
const selectionCellCounts: number[] = []
704723

705724
for (const frame of frames) {
706725
if (!frame.buffers?.bg) continue
707-
708-
let selectedCells = 0
709-
for (let y = editor.y; y < editor.y + editor.height; y++) {
710-
for (let x = editor.x; x < editor.x + editor.width; x++) {
711-
const bufferIdx = y * bufferWidth + x
712-
const bgG = (frame.buffers.bg[bufferIdx * 4 + 1] & 0xff) / 255
713-
if (Math.abs(bgG - 1.0) < 0.01) {
714-
selectedCells++
715-
}
716-
}
717-
}
718-
selectionCellCounts.push(selectedCells)
726+
selectionCellCounts.push(countSelectedCells(frame.buffers.bg, bufferWidth, editorBounds))
719727
}
720728

721729
const firstFrameSelection = selectionCellCounts[0] || 0

0 commit comments

Comments
 (0)