Skip to content

Commit

Permalink
chore: restore 'bat_async' as default bat previewer
Browse files Browse the repository at this point in the history
process spawned by libuv will be killed if selected
item changes before the preview process exits
  • Loading branch information
ibhagwan committed Feb 17, 2023
1 parent 6eb7377 commit 2d4e3af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ M.defaults = {
args = "--italic-text=always --style=numbers,changes --color always",
theme = nil,
config = nil,
_ctor = previewers.fzf.bat,
_ctor = previewers.fzf.bat_async,
},
bat_native = {
cmd = "bat",
Expand Down
2 changes: 1 addition & 1 deletion lua/fzf-lua/providers/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local function tags(opts)
opts.__module__ = opts.__module__ or "tags"

-- make sure we have the correct 'bat' previewer for tags
if opts.previewer == "bat" then opts.previewer = "bat_async" end
if opts.previewer == "bat_native" then opts.previewer = "bat_async" end

-- signal actions this is a ctag
opts._ctag = true
Expand Down
4 changes: 4 additions & 0 deletions lua/fzf-lua/shell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ M.raw_preview_action_cmd = function(fn, fzf_field_expression, debug)
end
end

libuv.process_kill(M.__pid_preview)
M.__pid_preview = nil

return libuv.spawn({
cmd = fn(...),
cb_finish = on_finish,
cb_write = on_write,
cb_pid = function(pid) M.__pid_preview = pid end,
}, false)
end, fzf_field_expression, debug)
end
Expand Down

0 comments on commit 2d4e3af

Please sign in to comment.