feat: add user autocmd TelescopeResumePost (#2433)
This commit is contained in:
committed by
GitHub
parent
9f501680e5
commit
18b7479542
@@ -539,6 +539,7 @@ Telescope user autocmds:
|
|||||||
|---------------------------------|---------------------------------------------------------|
|
|---------------------------------|---------------------------------------------------------|
|
||||||
| `User TelescopeFindPre` | Do it before Telescope creates all the floating windows |
|
| `User TelescopeFindPre` | Do it before Telescope creates all the floating windows |
|
||||||
| `User TelescopePreviewerLoaded` | Do it after Telescope previewer window is created |
|
| `User TelescopePreviewerLoaded` | Do it after Telescope previewer window is created |
|
||||||
|
| `User TelescopeResumePost` | Do it after Telescope resume action is fully completed |
|
||||||
|
|
||||||
## Extensions
|
## Extensions
|
||||||
|
|
||||||
|
|||||||
@@ -1559,15 +1559,24 @@ function Picker:_resume_picker()
|
|||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
self.cache_picker.is_cached = false
|
self.cache_picker.is_cached = false
|
||||||
|
local on_resume_complete = function()
|
||||||
|
if vim.api.nvim_buf_is_valid(self.prompt_bufnr) then
|
||||||
|
vim.api.nvim_buf_call(self.prompt_bufnr, function()
|
||||||
|
vim.cmd "do User TelescopeResumePost"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- if text changed, required to set anew to restart finder; otherwise hl and selection
|
-- if text changed, required to set anew to restart finder; otherwise hl and selection
|
||||||
if self.cache_picker.cached_prompt ~= self.default_text then
|
if self.cache_picker.cached_prompt ~= self.default_text then
|
||||||
self:set_prompt(self.default_text)
|
self:set_prompt(self.default_text)
|
||||||
|
on_resume_complete()
|
||||||
else
|
else
|
||||||
-- scheduling required to apply highlighting and selection appropriately
|
-- scheduling required to apply highlighting and selection appropriately
|
||||||
await_schedule(function()
|
await_schedule(function()
|
||||||
if self.cache_picker.selection_row ~= nil then
|
if self.cache_picker.selection_row ~= nil then
|
||||||
self:set_selection(self.cache_picker.selection_row)
|
self:set_selection(self.cache_picker.selection_row)
|
||||||
end
|
end
|
||||||
|
on_resume_complete()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user