From 25b1bc8f17e1b658551cf2435fa2070dc96edc4e Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Mon, 13 Jun 2022 18:53:16 +0200 Subject: feat: clear previewer if no item is selected (#2004) --- lua/telescope/pickers.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lua/telescope/pickers.lua') diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 9397c57..1a45cd4 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -965,6 +965,9 @@ function Picker:set_selection(row) state.set_global_key("selected_entry", entry) if not entry then + -- also refresh previewer when there is no entry selected, so the preview window is cleared + self._selection_entry = entry + self:refresh_previewer() return end @@ -1068,10 +1071,6 @@ end --- Refresh the previewer based on the current `status` of the picker function Picker:refresh_previewer() local status = state.get_status(self.prompt_bufnr) - if not self._selection_entry then - -- if selection_entry is nil there is nothing to be previewed - return - end if self.previewer and status.preview_win and a.nvim_win_is_valid(status.preview_win) then self:_increment "previewed" -- cgit v1.2.3