Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lua/fzf-lua/previewer/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,11 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
-- kill previously running jobs
self:_stop_preview_job()

if entry._scratch_buf then
self:set_preview_buf(entry._scratch_buf)
self:preview_buf_post(entry)
return
end
-- check if cached is update-to-date to be reuse
local cached, stale = self.bcache:check(entry)
entry.cached = cached
Expand Down
12 changes: 11 additions & 1 deletion lua/fzf-lua/providers/ui_select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,17 @@ M.ui_select = function(items, ui_opts, on_choice)
_ctor = function()
local previewer = require("fzf-lua.previewer.builtin").buffer_or_file:extend()
---@diagnostic disable-next-line: unused
function previewer:parse_entry(entry_str, cb) return ui_opts.preview_item(entry_str, cb) end
function previewer:parse_entry(entry_str, cb)
local res = assert(ui_opts.preview_item(entry_str, cb))
local pos_start, pos_end = res.pos, res.pos_end
return {
_scratch_buf = res.buf,
line = pos_start and pos_start[1] or 1,
col = pos_start and pos_start[2] or 1,
end_line = pos_end and pos_end[1] or 1,
end_col = pos_end and pos_end[2] or 1,
}
end
Comment thread
phanen marked this conversation as resolved.

return previewer
end
Expand Down
1 change: 1 addition & 0 deletions lua/fzf-lua/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local FzfLua = require("fzf-lua")
---@field end_col? integer 1-based
---@field open_term? boolean open_term for content (cmd always open_term)
---@field cache_key? any unique cache key for entry (to reuse preview buffer)
---@field _scratch_buf? integer "unmanaged" buffer

---@class fzf-lua.keymap.Entry: fzf-lua.buffer_or_file.Entry
---@field vmap string?
Expand Down
Loading