diff --git a/packages/tui/src/components/image.ts b/packages/tui/src/components/image.ts index 876996f3..74992b34 100644 --- a/packages/tui/src/components/image.ts +++ b/packages/tui/src/components/image.ts @@ -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 { diff --git a/packages/tui/test/terminal-image.test.ts b/packages/tui/test/terminal-image.test.ts index bdb2220c..58e018d2 100644 --- a/packages/tui/test/terminal-image.test.ts +++ b/packages/tui/test/terminal-image.test.ts @@ -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();