дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 05:22:23 +02:00
xterm 6.0.0 anchors the IME candidate window and preedit to its helper textarea, which only follows the cursor while no composition runs. Agent TUIs park the cursor at the end of a chunked redraw, so a composition starting then appeared at the far edge. 6.0.0 also left the viewport at line 0 after ESC[3J trimmed the scrollback. Both are fixed upstream in 6.1 (xtermjs#5759, #6046), which is only available as a beta. - Move @xterm/xterm, addon-fit and addon-search to the 6.1 betas, pinned to exact versions until 6.1 is stable. - Adapt to overviewRuler -> scrollbar (option and DOM class names) and to the DOM renderer's new createRow blink arguments in the cached renderRows; the version guard refuses renderers without them. - Re-check the IME patches against 6.1 and update their rationale. - Stub a 2D canvas context in the test setup, which 6.1's renderer needs under jsdom. Co-authored-by: H-TWINKLE <[email protected]>
71 рядки
3.1 KiB
TypeScript
71 рядки
3.1 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
import { afterEach } from "vitest";
|
|
import { cleanup } from "@testing-library/react";
|
|
|
|
afterEach(() => cleanup());
|
|
|
|
// jsdom has no layout: give elements a size so virtualized lists render rows.
|
|
if (typeof window !== "undefined") {
|
|
// jsdom's user agent names the host OS; tests are written for macOS (⌘ keymaps) and opt into Windows explicitly.
|
|
Object.defineProperty(window.navigator, "userAgent", {
|
|
configurable: true,
|
|
get: () => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) jsdom",
|
|
});
|
|
Object.defineProperty(HTMLElement.prototype, "clientHeight", { configurable: true, get: () => 600 });
|
|
Object.defineProperty(HTMLElement.prototype, "clientWidth", { configurable: true, get: () => 400 });
|
|
Object.defineProperty(HTMLElement.prototype, "offsetHeight", { configurable: true, get: () => 600 });
|
|
Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, get: () => 400 });
|
|
|
|
if (!("ResizeObserver" in window)) {
|
|
class ResizeObserverStub {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
(window as unknown as { ResizeObserver: unknown }).ResizeObserver = ResizeObserverStub;
|
|
(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = ResizeObserverStub;
|
|
}
|
|
if (!window.matchMedia) {
|
|
window.matchMedia = (query: string) =>
|
|
({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addEventListener() {},
|
|
removeEventListener() {},
|
|
addListener() {},
|
|
removeListener() {},
|
|
dispatchEvent: () => false,
|
|
}) as MediaQueryList;
|
|
}
|
|
Element.prototype.scrollIntoView ??= function () {};
|
|
// xterm 6.1 measures glyph widths on a 2D canvas; jsdom has none, and its renderer
|
|
// throws without a context. Every glyph counts as one 8px cell, which is all the
|
|
// tests read (they assert markup and classes, not pixels).
|
|
const context2d = {
|
|
font: "",
|
|
fillRect() {},
|
|
fillText() {},
|
|
measureText: (text: string) => ({
|
|
width: text.length * 8,
|
|
fontBoundingBoxAscent: 8,
|
|
fontBoundingBoxDescent: 2,
|
|
}),
|
|
} as unknown as CanvasRenderingContext2D;
|
|
HTMLCanvasElement.prototype.getContext = ((contextId: string) =>
|
|
contextId === "2d" ? context2d : null) as HTMLCanvasElement["getContext"];
|
|
// No layout either: CodeMirror measures text ranges when it positions the caret,
|
|
// tooltips and line heights, sometimes in an animation frame after a test ends.
|
|
Range.prototype.getClientRects ??= () => Object.assign([], { item: () => null }) as unknown as DOMRectList;
|
|
Range.prototype.getBoundingClientRect ??= () => new DOMRect();
|
|
Element.prototype.scrollTo ??= function () {} as Element["scrollTo"];
|
|
if (!("Highlight" in globalThis)) {
|
|
class HighlightStub extends Set<AbstractRange> {
|
|
priority = 0;
|
|
}
|
|
(globalThis as unknown as { Highlight: unknown }).Highlight = HighlightStub;
|
|
}
|
|
const gCss = ((globalThis as unknown as { CSS?: Record<string, unknown> }).CSS ??= {});
|
|
gCss.highlights ??= new Map<string, Set<AbstractRange>>();
|
|
}
|