@@ -942,20 +942,6 @@ function Previewer.buffer_or_file:_populate_cmd_preview(tmpbuf, entry, entry_str
942942 end
943943end
944944
945- --- @param tmpbuf integer
946- --- @param entry fzf-lua.buffer_or_file.Entry
947- --- @return nil
948- function Previewer .buffer_or_file :_populate_file_preview (tmpbuf , entry )
949- utils .read_file_async (entry .path , vim .schedule_wrap (function (data )
950- -- if file ends in new line, don't write an empty string as the last
951- -- line.
952- api .nvim_buf_set_lines (tmpbuf , 0 , - 1 , false , split_file_data (data ))
953- -- swap preview buffer with new one
954- self :set_preview_buf (tmpbuf )
955- self :preview_buf_post (entry )
956- end ))
957- end
958-
959945--- @async
960946--- @param entry_str string
961947--- @return false ? no preview
@@ -1004,7 +990,14 @@ function Previewer.buffer_or_file:populate_preview_buf(entry_str)
1004990 if entry .content then
1005991 return self :_set_preview_lines (buf , entry )
1006992 end
1007- self :_populate_file_preview (buf , entry )
993+ utils .read_file_async (entry .path , vim .schedule_wrap (function (data )
994+ if entry_str ~= self ._last_entry then return end
995+ -- if file ends in new line, don't write an empty string as the last line.
996+ api .nvim_buf_set_lines (buf , 0 , - 1 , false , split_file_data (data ))
997+ -- swap preview buffer with new one
998+ self :set_preview_buf (buf )
999+ self :preview_buf_post (entry )
1000+ end ))
10081001end
10091002
10101003-- Attach ts highlighter, neovim >= v0.9
0 commit comments