feat: add user autocmd TelescopeResumePost (#2433)

This commit is contained in:
Andrii Berezhynskyi
2023-05-24 09:41:59 +00:00
committed by GitHub
parent 9f501680e5
commit 18b7479542
2 changed files with 10 additions and 0 deletions

View File

@@ -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

View File

@@ -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