From 04ad8fe861ded0809f2997acddee1a9d37de8f89 Mon Sep 17 00:00:00 2001 From: 3rd <3rd@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:38:13 +0200 Subject: [PATCH] fix: max width/height should not depend on scroll position https://github.com/3rd/image.nvim/issues/87 --- lua/image/renderer.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/image/renderer.lua b/lua/image/renderer.lua index c4b339c..9250860 100644 --- a/lua/image/renderer.lua +++ b/lua/image/renderer.lua @@ -121,15 +121,20 @@ local render = function(image) -- global max window width/height percentage if type(state.options.max_width_window_percentage) == "number" then - width = math.min(width, math.floor((window.width - x_offset) * state.options.max_width_window_percentage / 100)) + width = + math.min(width, math.floor((window.width - global_offsets.x) * state.options.max_width_window_percentage / 100)) end if type(state.options.max_height_window_percentage) == "number" then - height = - math.min(height, math.floor((window.height - y_offset) * state.options.max_height_window_percentage / 100)) + height = math.min( + height, + math.floor((window.height - global_offsets.y) * state.options.max_height_window_percentage / 100) + ) end end - -- utils.debug(("(2) x: %d, y: %d, width: %d, height: %d y_offset: %d"):format(original_x, original_y, width, height, y_offset)) + utils.debug( + ("(2) x: %d, y: %d, width: %d, height: %d y_offset: %d"):format(original_x, original_y, width, height, y_offset) + ) -- global max width/height if type(state.options.max_width) == "number" then width = math.min(width, state.options.max_width) end