fix(which_key): close window on mouse click action (#3053)

* fix(which_key): close window on mouse click action

`nvim_buf_delete` is not allowed during text change or window change.
Window switching with left mouse click was leading to race
condition/error.

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
This commit is contained in:
James Trew
2024-04-15 21:03:24 -04:00
committed by GitHub
parent a3284957d3
commit d00d9df48c
2 changed files with 7 additions and 3 deletions

View File

@@ -3678,6 +3678,8 @@ action_generate.which_key({opts}) *telescope.actions.generate.which_key()*
"TelescopePromptBorder")
{winblend} (number) pseudo-transparency of keymap
hints floating window
{zindex} (number) z-index of keymap hints floating
window (default: 100)

View File

@@ -1428,9 +1428,11 @@ actions.which_key = function(prompt_bufnr, opts)
buffer = close_buffer,
once = true,
callback = function()
pcall(vim.api.nvim_win_close, km_win_id, true)
pcall(vim.api.nvim_win_close, km_opts.border.win_id, true)
require("telescope.utils").buf_delete(km_buf)
vim.schedule(function()
pcall(vim.api.nvim_win_close, km_win_id, true)
pcall(vim.api.nvim_win_close, km_opts.border.win_id, true)
utils.buf_delete(km_buf)
end)
end,
})
end)