Skip to content

Commit

Permalink
feat(window): make work with wrapped lines
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Oct 13, 2024
1 parent 0659d9c commit 42a1f6e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/care/utils/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 42a1f6e

Please sign in to comment.