terminal/kitty: preserve image limits across full reset

RIS previously cleared configured storage limits and allowed mediums. 
We now retain this properly.
This commit is contained in:
Mitchell Hashimoto
2026-08-21 08:02:26 -07:00
parent 99d7b5fd50
commit bcbc93a6b9
2 changed files with 33 additions and 1 deletions

View File

@@ -417,8 +417,14 @@ pub fn reset(self: *Screen) void {
if (comptime build_options.kitty_graphics) {
// Reset kitty graphics storage
const image_limits = self.kitty_images.image_limits;
const total_limit = self.kitty_images.total_limit;
self.kitty_images.deinit(self.alloc, self);
self.kitty_images = .{ .dirty = true };
self.kitty_images = .{
.dirty = true,
.image_limits = image_limits,
.total_limit = total_limit,
};
}
// Reset our basic state

View File

@@ -15406,6 +15406,32 @@ test "Terminal: fullReset status display" {
try testing.expect(t.status_display == .main);
}
test "Terminal: fullReset preserves kitty graphics limits" {
const alloc = testing.allocator;
const temp_dir = "/tmp/ghostty-kitty-images";
var t = try init(testing.io, alloc, .{ .cols = 10, .rows = 10 });
defer t.deinit(alloc);
t.setKittyGraphicsLoadingLimits(.allWithTempDir(temp_dir));
for ([_]usize{ 1234, 0 }) |total_limit| {
t.setKittyGraphicsSizeLimit(alloc, total_limit);
t.fullReset();
const storage = &t.screens.active.kitty_images;
try testing.expectEqual(total_limit, storage.total_limit);
try testing.expect(storage.image_limits.file);
try testing.expect(storage.image_limits.shared_memory);
switch (storage.image_limits.temporary_file) {
.enabled => |value| try testing.expectEqualStrings(
temp_dir,
value.directory,
),
.disabled => return error.TestUnexpectedResult,
}
}
}
// https://github.com/mitchellh/ghostty/issues/1607
test "Terminal: fullReset clears alt screen kitty keyboard state" {
var t = try init(testing.io, testing.allocator, .{ .cols = 10, .rows = 10 });