diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 143af11..3c2c2d4 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -1227,7 +1227,7 @@ end --- Close all open Telescope pickers function Picker:close_existing_pickers() - for _, prompt_bufnr in ipairs(state.get_existing_prompts()) do + for _, prompt_bufnr in ipairs(state.get_existing_prompt_bufnrs()) do pcall(actions.close, prompt_bufnr) end end diff --git a/lua/telescope/state.lua b/lua/telescope/state.lua index 6a06eb1..a3e6d85 100644 --- a/lua/telescope/state.lua +++ b/lua/telescope/state.lua @@ -24,8 +24,16 @@ function state.clear_status(prompt_bufnr) state.set_status(prompt_bufnr, nil) end -function state.get_existing_prompts() - return vim.tbl_keys(TelescopeGlobalState) +function state.get_existing_prompt_bufnrs() + local prompt_bufnrs = {} + + for key, _ in pairs(TelescopeGlobalState) do + if type(key) == "number" then + table.insert(prompt_bufnrs, key) + end + end + + return prompt_bufnrs end return state