Skip to content

Commit

Permalink
fix preview win highlights in 'buffers' (issue #169)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Oct 6, 2021
1 parent a499bd7 commit 5688508
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lua/fzf-lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ M.globals.grep = {
file_icons = true and M._has_devicons,
color_icons = true,
git_icons = true,
grep_opts = "--line-number --recursive --color=auto --perl-regexp",
grep_opts = "--binary-files=without-match --line-number --recursive --color=auto --perl-regexp",
rg_opts = "--column --line-number --no-heading --color=always --smart-case",
actions = M.globals.files.actions,
}
Expand Down
35 changes: 21 additions & 14 deletions lua/fzf-lua/previewer/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,39 @@ function Previewer.base:display_entry(entry_str)
-- store the new preview buffer
self.preview_bufnr = self:clear_preview_buf()

-- specialized previewer populate function
local populate_preview_buf = function(entry_str)
if not self.win or not self.win:validate_preview() then return end

-- specialized previewer populate function
self:populate_preview_buf(entry_str)

-- is the preview a terminal buffer (alternative way)
--[[ local is_terminal =
vim.fn.getwininfo(self.win.preview_winid)[1].terminal == 1 ]]

-- set preview window options
if not utils.is_term_buffer(self.preview_bufnr) then
self:set_winopts(self.win.preview_winid)
end

-- reset the preview window highlights
self.win:reset_win_highlights(self.win.preview_winid)
end

if not self._entry_count then self._entry_count=1
else self._entry_count = self._entry_count+1 end
local entry_count = self._entry_count
if self.delay>0 then
vim.defer_fn(function()
-- only display if entry hasn't changed
if self._entry_count == entry_count then
self:populate_preview_buf(entry_str)
populate_preview_buf(entry_str)
end
end, self.delay)
else
self:populate_preview_buf(entry_str)
end

-- is the preview a terminal buffer (alternative way)
--[[ local is_terminal =
vim.fn.getwininfo(self.win.preview_winid)[1].terminal == 1 ]]

-- set preview window options
if not utils.is_term_buffer(self.preview_bufnr) then
self:set_winopts(self.win.preview_winid)
populate_preview_buf(entry_str)
end

-- reset the preview window highlights
self.win:reset_win_highlights(self.win.preview_winid)
end

function Previewer.base:action(_)
Expand Down

0 comments on commit 5688508

Please sign in to comment.