fix(tui): remove explicit image ids

This commit is contained in:
Armin Ronacher
2026-05-07 10:40:15 +02:00
parent b8712457d2
commit 83a917073c
2 changed files with 5 additions and 6 deletions

View File

@@ -27,7 +27,6 @@ export class Image implements Component {
private theme: ImageTheme;
private options: ImageOptions;
private imageId?: number;
private readonly explicitImageId?: number;
private cachedLines?: string[];
private cachedWidth?: number;
@@ -44,13 +43,12 @@ export class Image implements Component {
this.theme = theme;
this.options = options;
this.dimensions = dimensions || getImageDimensions(base64Data, mimeType) || { widthPx: 800, heightPx: 600 };
this.explicitImageId = options.imageId;
this.imageId = options.imageId;
}
/** Get the explicit Kitty image ID configured for this image (if any). */
/** Get the Kitty image ID used by this image (if any). */
getImageId(): number | undefined {
return this.explicitImageId;
return this.imageId;
}
invalidate(): void {

View File

@@ -324,11 +324,12 @@ describe("Kitty image cursor movement", () => {
{ widthPx: 20, heightPx: 20 },
);
const lines = image.render(4);
assert.strictEqual(image.getImageId(), undefined);
const imageId = image.getImageId();
assert.strictEqual(typeof imageId, "number");
assert.deepStrictEqual(lines.slice(0, -1), [""]);
assert.ok(lines[1].startsWith("\x1b[1A\x1b_G"));
assert.ok(lines[1].includes(",C=1,"));
assert.ok(lines[1].includes(",i="));
assert.ok(lines[1].includes(`,i=${imageId}`));
assert.ok(lines[1].endsWith("\x1b[1B"));
} finally {
resetCapabilitiesCache();