Skip to content

Commit d637241

Browse files
committed
fix(preview): ignore snacks.image namespace when copy_extmarks
It can make math symbol placed twice in loaded markdown buffer.
1 parent f93d87f commit d637241

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,16 @@ local copy_extmarks = function(src_buf, buf, win, topline, botline, ns)
636636
api.nvim_buf_clear_namespace(buf, ns, topline, botline)
637637
local extmarks = api.nvim_buf_get_extmarks(src_buf, -1, { topline, 0 }, { botline, -1 },
638638
{ details = true })
639+
local namespaces = api.nvim_get_namespaces()
640+
local ignore = {}
641+
if namespaces["snacks.image"] then ignore[namespaces["snacks.image"]] = true end
639642
for _, m in ipairs(extmarks) do
640643
local _, row, col, details = unpack(m) ---@cast details -?
641-
details.ns_id = nil
642-
if no_virt_text and details.virt_text then details.virt_text = nil end
643-
pcall(api.nvim_buf_set_extmark, buf, ns, row, col, details)
644+
if not ignore[details.ns_id] then
645+
details.ns_id = nil
646+
if no_virt_text and details.virt_text then details.virt_text = nil end
647+
pcall(api.nvim_buf_set_extmark, buf, ns, row, col, details)
648+
end
644649
end
645650
end
646651

0 commit comments

Comments
 (0)