From 4681dcdffe20e1f23b6b9ccf28836537ed166c47 Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Thu, 5 May 2022 10:05:37 +0200 Subject: [PATCH] fix: another teardown issue (#1918) --- lua/telescope/pickers.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 1d20df1..d2c6e2b 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -743,9 +743,9 @@ function Picker.close_windows(status) utils.win_delete("results_border_win", status.results_border_win, true, true) utils.win_delete("preview_border_win", status.preview_border_win, true, true) - vim.defer_fn(function() - utils.win_delete("prompt_win", status.prompt_win, true) - end, 10) + -- we cant use win_delete. We first need to close and then delete the buffer + vim.api.nvim_win_close(status.prompt_win, true) + utils.buf_delete(status.prompt_bufnr) state.clear_status(status.prompt_bufnr) end @@ -1463,13 +1463,14 @@ function pickers.on_close_prompt(prompt_bufnr) picker.finder:close() end - picker.close_windows(status) - mappings.clear(prompt_bufnr) + -- so we dont call close_windows multiple times we clear that autocmd vim.api.nvim_clear_autocmds { group = "PickerInsert", event = "BufLeave", buffer = prompt_bufnr, } + picker.close_windows(status) + mappings.clear(prompt_bufnr) end function pickers.on_resize_window(prompt_bufnr)