Skip to content

Commit bc0630e

Browse files
committed
feat(image.inline): honor concealcursor and hide conceal when selecting lines. Closes #1478
1 parent 1ce9133 commit bc0630e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lua/snacks/image/inline.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ function M.new(buf)
3535
end
3636

3737
function M:conceal()
38-
local mode = vim.fn.mode()
39-
local cursor = vim.api.nvim_win_get_cursor(0)
40-
local by_mode = not mode:find("[nc]")
41-
local hide = by_mode and self:visible() or self:get(cursor[1], cursor[1])
38+
local mode = vim.fn.mode():sub(1, 1):lower() ---@type string
4239
for _, img in pairs(self.imgs) do
4340
img:show()
4441
end
42+
if vim.wo.concealcursor:find(mode) then
43+
return
44+
end
45+
local from, to = vim.fn.line("v"), vim.fn.line(".")
46+
from, to = math.min(from, to), math.max(from, to)
47+
local hide = self:get(from, to)
4548
for _, img in pairs(hide) do
46-
if by_mode or img.opts.conceal then
49+
if img.opts.conceal then
4750
img:hide()
4851
end
4952
end

0 commit comments

Comments
 (0)