fix(telescope.state.get_existing_prompts): it should only return keys that are numbers (#2684)
* fix(telescope.state.get_existing_prompts): it should only return keys that are numbers * Table keys not table values should be numbers * Rename get_existing_prompts to get_existing_prompt_bufnrs and make the impl more efficient
This commit is contained in:
committed by
GitHub
parent
6b79d7a6a4
commit
20a37e43bb
@@ -1227,7 +1227,7 @@ end
|
|||||||
|
|
||||||
--- Close all open Telescope pickers
|
--- Close all open Telescope pickers
|
||||||
function Picker:close_existing_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)
|
pcall(actions.close, prompt_bufnr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,8 +24,16 @@ function state.clear_status(prompt_bufnr)
|
|||||||
state.set_status(prompt_bufnr, nil)
|
state.set_status(prompt_bufnr, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
function state.get_existing_prompts()
|
function state.get_existing_prompt_bufnrs()
|
||||||
return vim.tbl_keys(TelescopeGlobalState)
|
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
|
end
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|||||||
Reference in New Issue
Block a user