Skip to content

Commit 23c0124

Browse files
committed
refactor(previewer): remove should_load_buffer
"load_buffer" is a bad name, a better name is "should_set_(preview)_buf" The asserted condition is way much better/simpler than it
1 parent 1d7ade4 commit 23c0124

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,6 @@ function Previewer.buffer_or_file:should_clear_preview(_)
592592
return false
593593
end
594594

595-
---@param entry fzf-lua.buffer_or_file.Entry|{}
596-
---@return boolean
597-
function Previewer.buffer_or_file:should_load_buffer(entry)
598-
-- we don't have a previous entry to compare to or `do_not_cache` is set meaning
599-
-- it's a terminal command (chafa, viu, ueberzug) which requires a reload
600-
-- return 'true' so the buffer will be loaded in ::populate_preview_buf
601-
if not self.loaded_entry or self.loaded_entry.do_not_cache then return true end
602-
return self.loaded_entry.cached ~= entry.cached
603-
end
604-
605595
function Previewer.buffer_or_file:start_ueberzug()
606596
if self._ueberzug_fifo then return self._ueberzug_fifo end
607597
self._ueberzug_fifo = path.join({
@@ -875,10 +865,9 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
875865
if entry_str ~= self._last_entry or not self.win:validate_preview() then return false end
876866
if utils.tbl_isempty(entry) then return end
877867
local cached = self:check_bcache(entry)
878-
if cached and not cached.invalid and not self:should_load_buffer(entry) then
879-
assert(cached.bufnr == self.preview_bufnr)
880-
-- same file/buffer as previous entry no need to reload content
881-
-- only call post to set cursor location
868+
869+
-- same file/buffer as previous entry no need to change preview buf
870+
if cached and not cached.invalid and cached.bufnr == self.preview_bufnr then
882871
if type(self.cached_bufnrs[self.preview_bufnr]) == "table"
883872
and ((entry.line and entry.line > 0 and entry.line ~= self.orig_pos[1])
884873
or (entry.col and entry.col > 0 and entry.col - 1 ~= self.orig_pos[2])) then

0 commit comments

Comments
 (0)