Skip to content

Commit c86b72c

Browse files
phanenibhagwan
authored andcommitted
fix: cancel previous entry if we are previewing different entry
The execute order of parse_entry callback can be random when it's slow (e.g. callback in network request) self:debounce don't work here, because we run a async parse_entry callback again in the debounce timer callback
1 parent c379132 commit c86b72c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,9 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
919919
-- schedule can avoid "cannot resume running coroutine"
920920
local entry = self:parse_entry(entry_str,
921921
vim.schedule_wrap(function(res) assert(coroutine.resume(co, res)) end))
922+
self._last_entry = entry_str
922923
entry = entry or coroutine.yield()
923-
if not self.win:validate_preview() then return false end
924+
if entry_str ~= self._last_entry or not self.win:validate_preview() then return false end
924925
if utils.tbl_isempty(entry) then return end
925926
local cached = self:check_bcache(entry)
926927
if cached and not cached.invalid and not self:should_load_buffer(entry) then

0 commit comments

Comments
 (0)