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:
@@ -185,7 +185,9 @@ previewers.new_buffer_previewer = function(opts)
|
|||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
set_bufnr(self, bufnr)
|
set_bufnr(self, bufnr)
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
|
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
|
||||||
|
end)
|
||||||
|
|
||||||
-- TODO(conni2461): We only have to set options once. Right?
|
-- TODO(conni2461): We only have to set options once. Right?
|
||||||
vim.api.nvim_win_set_option(status.preview_win, 'winhl', 'Normal:TelescopePreviewNormal')
|
vim.api.nvim_win_set_option(status.preview_win, 'winhl', 'Normal:TelescopePreviewNormal')
|
||||||
|
|||||||
Reference in New Issue
Block a user