From 42a1f6e45955ee77e465db7a34ac0b1423b04825 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 13 Oct 2024 10:00:00 +0200 Subject: [PATCH] feat(window): make work with wrapped lines --- lua/care/utils/window.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/care/utils/window.lua b/lua/care/utils/window.lua index 1e3f8e5..6439fd5 100644 --- a/lua/care/utils/window.lua +++ b/lua/care/utils/window.lua @@ -33,6 +33,17 @@ function Window:open_cursor_relative(width, wanted_height, offset, config) local row = screenpos.row local col = offset + if screenpos.row ~= cursor[1] then + -- on a wrapped line + local delta = cursor[2] + - offset + + vim.fn.getwininfo(vim.api.nvim_get_current_win())[1].wincol + + vim.fn.getwininfo(vim.api.nvim_get_current_win())[1].textoff + - 1 + + col = screenpos.col - delta + end + local space_below = vim.o.lines - screenpos.row - vim.o.cmdheight - 1 local space_above = screenpos.row - 1