fix: Close existing pickers when starting new one. Fix #102
This commit is contained in:
@@ -250,6 +250,7 @@ function Picker:can_select_row(row)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Picker:find()
|
function Picker:find()
|
||||||
|
self:close_existing_pickers()
|
||||||
self:reset_selection()
|
self:reset_selection()
|
||||||
|
|
||||||
local prompt_string = assert(self.prompt, "Prompt is required.")
|
local prompt_string = assert(self.prompt, "Prompt is required.")
|
||||||
@@ -649,6 +650,13 @@ function Picker:set_selection(row)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Picker:close_existing_pickers()
|
||||||
|
for _, prompt_bufnr in ipairs(state.get_existing_prompts()) do
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
pickers.new = function(opts, defaults)
|
pickers.new = function(opts, defaults)
|
||||||
opts = extend(opts, defaults)
|
opts = extend(opts, defaults)
|
||||||
return Picker:new(opts)
|
return Picker:new(opts)
|
||||||
|
|||||||
@@ -15,4 +15,8 @@ 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()
|
||||||
|
return vim.tbl_keys(TelescopeGlobalState)
|
||||||
|
end
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|||||||
Reference in New Issue
Block a user