Skip to content

Commit

Permalink
fix: position relative nearby virtual text
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed Nov 16, 2023
1 parent 4c1c903 commit 4d18722
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lua/image/image.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ local createImage = function(template, global_state)
return instance
end

---get the extmark id for the virtual padding for this image
---@return number?
function Image:get_extmark_id()
local extmark = buf_extmark_map[self.buffer .. ":" .. self.geometry.y]
if extmark then
return extmark.id
end
end

---@param geometry? ImageGeometry
function Image:render(geometry)
if geometry then self.geometry = vim.tbl_deep_extend("force", self.geometry, geometry) end
Expand Down
4 changes: 3 additions & 1 deletion lua/image/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ local render = function(image)

local offset = topfill
for _, mark in ipairs(extmarks) do
if mark.row + 1 ~= original_y then offset = offset + mark.height end
if mark.row ~= original_y and mark.id ~= image:get_extmark_id() then
offset = offset + mark.height
end
end

absolute_y = absolute_y + offset
Expand Down

0 comments on commit 4d18722

Please sign in to comment.