fix(tui): remove explicit image ids
This commit is contained in:
@@ -27,7 +27,6 @@ export class Image implements Component {
|
|||||||
private theme: ImageTheme;
|
private theme: ImageTheme;
|
||||||
private options: ImageOptions;
|
private options: ImageOptions;
|
||||||
private imageId?: number;
|
private imageId?: number;
|
||||||
private readonly explicitImageId?: number;
|
|
||||||
|
|
||||||
private cachedLines?: string[];
|
private cachedLines?: string[];
|
||||||
private cachedWidth?: number;
|
private cachedWidth?: number;
|
||||||
@@ -44,13 +43,12 @@ export class Image implements Component {
|
|||||||
this.theme = theme;
|
this.theme = theme;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.dimensions = dimensions || getImageDimensions(base64Data, mimeType) || { widthPx: 800, heightPx: 600 };
|
this.dimensions = dimensions || getImageDimensions(base64Data, mimeType) || { widthPx: 800, heightPx: 600 };
|
||||||
this.explicitImageId = options.imageId;
|
|
||||||
this.imageId = 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 {
|
getImageId(): number | undefined {
|
||||||
return this.explicitImageId;
|
return this.imageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate(): void {
|
invalidate(): void {
|
||||||
|
|||||||
@@ -324,11 +324,12 @@ describe("Kitty image cursor movement", () => {
|
|||||||
{ widthPx: 20, heightPx: 20 },
|
{ widthPx: 20, heightPx: 20 },
|
||||||
);
|
);
|
||||||
const lines = image.render(4);
|
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.deepStrictEqual(lines.slice(0, -1), [""]);
|
||||||
assert.ok(lines[1].startsWith("\x1b[1A\x1b_G"));
|
assert.ok(lines[1].startsWith("\x1b[1A\x1b_G"));
|
||||||
assert.ok(lines[1].includes(",C=1,"));
|
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"));
|
assert.ok(lines[1].endsWith("\x1b[1B"));
|
||||||
} finally {
|
} finally {
|
||||||
resetCapabilitiesCache();
|
resetCapabilitiesCache();
|
||||||
|
|||||||
Reference in New Issue
Block a user