From 9ccc6bf835a7525bf671f0a05b19b5d01c43bcf8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Jan 2018 13:54:51 +0530 Subject: [PATCH] Fix incorrect handling of zero extra pixel offset --- kitty/icat.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kitty/icat.py b/kitty/icat.py index af54ab8b8..15b0a2a6f 100755 --- a/kitty/icat.py +++ b/kitty/icat.py @@ -143,10 +143,12 @@ def fit_image(width, height, pwidth, pheight): def calculate_in_cell_x_offset(width, cell_width, align): if align == 'left': return 0 - extra_pixels = cell_width - (width % cell_width) + extra_pixels = width % cell_width + if not extra_pixels: + return 0 if align == 'right': - return extra_pixels - return extra_pixels // 2 + return cell_width - extra_pixels + return (cell_width - extra_pixels) // 2 def set_cursor(cmd, width, height, align):