Skip to content

Commit 916e886

Browse files
committed
fix(preview): copy all extmarks
to make it work with diffs.nvim
1 parent c86b72c commit 916e886

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,8 @@ function Previewer.base:copy_extmarks()
621621
{ details = true })
622622
for _, m in ipairs(extmarks) do
623623
local _, row, col, details = unpack(m) ---@cast details -?
624-
local endRow, endCol = details.end_row, details.end_col
625-
local hlGroup = details.hl_group
626-
local priority = details.priority
627-
pcall(api.nvim_buf_set_extmark, dst_bufnr, ns, row, col,
628-
{ end_row = endRow, end_col = endCol, hl_group = hlGroup, priority = priority })
624+
details.ns_id = nil
625+
pcall(api.nvim_buf_set_extmark, dst_bufnr, ns, row, col, details)
629626
end
630627
end
631628
end
@@ -688,16 +685,17 @@ function Previewer.buffer_or_file:parse_entry(entry_str, _cb)
688685
-- filename only
689686
if buf and api.nvim_buf_is_valid(buf) then
690687
entry.path = path.relative_to(api.nvim_buf_get_name(buf), utils.cwd())
691-
end
692-
if entry.path then
693-
if entry.path:find("^fugitive://") and buf and api.nvim_buf_is_valid(buf) then
694-
if fn.exists("#fugitive#BufReadCmd") == 1 then
695-
api.nvim_buf_call(buf, function()
696-
api.nvim_exec_autocmds("BufReadCmd", { group = "fugitive", pattern = entry.path })
697-
end)
698-
end
688+
if entry.path:find("^fugitive://") then
689+
api.nvim_buf_call(buf, function()
690+
api.nvim_exec_autocmds("BufReadCmd", {
691+
group = fn.exists("#fugitive#BufReadCmd") == 1 and "fugitive" or nil,
692+
pattern = entry.path
693+
})
694+
end)
699695
return entry
700696
end
697+
end
698+
if entry.path then
701699
entry.tick = vim.tbl_get(uv.fs_stat(entry.path) or {}, "mtime", "nsec")
702700
end
703701
return entry
@@ -1451,6 +1449,7 @@ function Previewer.buffer_or_file:preview_buf_post(entry, min_winopts)
14511449
self:update_render_markdown()
14521450
self:update_ts_context()
14531451
self:attach_snacks_image_inline()
1452+
vim.schedule(function() self:copy_extmarks() end)
14541453
end
14551454
-- for attach_snacks_image_{inline,buf}
14561455
-- https://github.com/folke/snacks.nvim/pull/1615

0 commit comments

Comments
 (0)