fix: prevents flickering when first loading a buffer preview entry (#797)

There's a slight lag on the first preview loading (during preview buffer creation).
It is not visible the next time user chooses a file for preview because scratch buffer
for the file already exists. This lag *and* setting preview window to display the newly
created buffer before its fully initialized causes a brief flash of blank terminal background.

This change delays setting preview window to display the new preview buffer and consequently
eliminates the flash. It should improve user experience since flickering can be distracting.
This commit is contained in:
Michał Nowotnik
2021-05-11 18:16:04 +00:00
committed by GitHub
parent 6dc69f46f6
commit 22a78a4636

View File

@@ -185,7 +185,9 @@ previewers.new_buffer_previewer = function(opts)
local bufnr = vim.api.nvim_create_buf(false, true)
set_bufnr(self, bufnr)
vim.schedule(function()
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
end)
-- TODO(conni2461): We only have to set options once. Right?
vim.api.nvim_win_set_option(status.preview_win, 'winhl', 'Normal:TelescopePreviewNormal')