-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ueberzug backend's y position being off by one #6
Conversation
@Vonr Hey, thank you so much for the PR! image.nvim/lua/image/renderer.lua Line 5 in 847f5d6
Been seeing the same issue on #5 |
That's interesting... So far all the images I've tested with work with this fix but ill look into renderer.lua. |
Might be line 109? |
local get_global_offsets = function()
local x = 0
local y = 0
if vim.opt.number then x = x + math.max(vim.opt.numberwidth:get(), ('' .. vim.api.nvim_buf_line_count(0)):len() + (vim.opt.relativenumber:get() and 1 or 0)) end
-- if vim.opt.signcolumn:get() ~= "no" then x = x + 2 end
if vim.opt.showtabline == 2 then y = y + 1 end
if vim.opt.winbar ~= "none" then y = y + 1 end
return { x = x, y = y }
end This fixes my left-right alignment but it probably breaks signcolumn alignment. |
local get_global_offsets = function()
local x = 0
local y = 0
local numberwidth = math.max(
vim.opt.numberwidth:get(),
('' .. vim.api.nvim_buf_line_count(0)):len()
+ (vim.opt.relativenumber:get() and 1 or 0))
if vim.opt.number then x = x + numberwidth end
local signcolumn = vim.opt.signcolumn:get()
if signcolumn ~= "no" then
x = x + math.max(0, 2 - (signcolumn == "number" and numberwidth or 0))
end
if vim.opt.showtabline == 2 then y = y + 1 end
if vim.opt.winbar ~= "none" then y = y + 1 end
return { x = x, y = y }
end This has a pretty decent chance of working for most setups, but I honestly have no idea. |
@Vonr that looks great, I'll test it out today and also add some unit tests for this, and we can merge it soon. |
|
||
local numberwidth = math.max( | ||
vim.opt.numberwidth:get(), | ||
('' .. vim.api.nvim_buf_line_count(0)):len() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are buffer-relative and this version applies the offsets for the active buffers to all the visible windows, looking into making this generic enough.
@@ -106,7 +117,7 @@ local render = function(image) | |||
-- global offsets | |||
local global_offsets = get_global_offsets() | |||
x_offset = global_offsets.x - window.scroll_x | |||
y_offset = global_offsets.y + 1 - window.scroll_y | |||
y_offset = global_offsets.y - window.scroll_y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, didn't see it because the winbar logic above is wrong.
Looks like it works, thank you! |
Before:
After: