From f4eea71859dd8eeb9b7f730959b4c472b73462fd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jul 2024 18:58:56 -0700 Subject: [PATCH] terminal/kitty: image dimensions off by one fix We weren't counting the original x/y as width 1. --- src/terminal/kitty/graphics_storage.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/terminal/kitty/graphics_storage.zig b/src/terminal/kitty/graphics_storage.zig index 547f78b97..ce91573f9 100644 --- a/src/terminal/kitty/graphics_storage.zig +++ b/src/terminal/kitty/graphics_storage.zig @@ -629,11 +629,17 @@ pub const ImageStorage = struct { ) Rect { const grid_size = self.gridSize(image, t); - var br = switch (self.pin.downOverflow(grid_size.rows)) { + var br = switch (self.pin.downOverflow(grid_size.rows - 1)) { .offset => |v| v, .overflow => |v| v.end, }; - br.x = @min(self.pin.x + grid_size.cols, t.cols - 1); + br.x = @min( + // We need to sub one here because the x value is + // one width already. So if the image is width "1" + // then we add zero to X because X itelf is width 1. + self.pin.x + (grid_size.cols - 1), + t.cols - 1, + ); return .{ .top_left = self.pin.*,