`on_choice` is not triggered when closing the window
przepompownia opened this issue · 6 comments
Minimal init.lua
:
local thisInitFile = debug.getinfo(1).source:match('@?(.*)')
local configDir = vim.fs.dirname(thisInitFile)
vim.env['XDG_CONFIG_HOME'] = configDir
vim.env['XDG_DATA_HOME'] = vim.fs.joinpath(configDir, '.xdg/data')
vim.env['XDG_STATE_HOME'] = vim.fs.joinpath(configDir, '.xdg/state')
vim.env['XDG_CACHE_HOME'] = vim.fs.joinpath(configDir, '.xdg/cache')
local stdPathConfig = vim.fn.stdpath('config')
vim.opt.runtimepath:prepend(stdPathConfig)
vim.opt.packpath:prepend(stdPathConfig)
local function gitClone(url, installPath, branch)
if vim.fn.isdirectory(installPath) ~= 0 then
return
end
local command = {'git', 'clone', '--depth=1', '--', url, installPath}
if branch then
table.insert(command, 3, '--branch')
table.insert(command, 4, branch)
end
local sysObj = vim.system(command, {}):wait()
if sysObj.code ~= 0 then
error(sysObj.stderr)
end
vim.notify(sysObj.stdout)
vim.notify(sysObj.stderr, vim.log.levels.WARN)
end
local pluginsPath = 'plugins'
vim.fn.mkdir(pluginsPath, 'p')
pluginsPath = vim.uv.fs_realpath(pluginsPath)
local plugins = {
['plenary'] = {url = 'https://github.com/nvim-lua/plenary.nvim'},
['telescope'] = {url = 'https://github.com/nvim-telescope/telescope.nvim'},
['telescope-ui-select'] = {url = 'https://github.com/nvim-telescope/telescope-ui-select.nvim'}
}
for name, repo in pairs(plugins) do
local installPath = vim.fs.joinpath(pluginsPath, name)
gitClone(repo.url, installPath, repo.branch)
vim.opt.runtimepath:append(installPath)
end
local function init()
require('telescope').setup {
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown {
}
}
},
}
require('telescope').load_extension('ui-select')
vim.ui.select({'x'}, {}, function (x, i)
vim.notify('After select')
vim.print(x, i)
end)
end
vim.api.nvim_create_autocmd('UIEnter', {
once = true,
callback = init,
})
After close by <Esc>
nothing happens in opposite to expected calling on_choice
callback with (nil
, nil
) like in https://github.com/neovim/neovim/blob/488038580934f301c1528a14548ec0cabd16c2cd/runtime/lua/vim/ui.lua#L52.
With #34 on_choice
is called with nil
as expected, thanks!
Independently, please notice that to cancel we need to exit Insert mode first and then close the dialog.
Independently, please notice that to cancel we need to exit Insert mode first and then close the dialog.
i dont know what that means?
In short, we need to press double Esc
to cancel.
thats a telescope configure thing, isnt it. like the default telescope esc action does not close, it switches modes. you can override this,s ee: https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#mapping-esc-to-quit-in-insert-mode
this is also documented here: https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#default-mappings
does this answer your question?
Ah, ok. I have this mapping for years but my observation came from the minimal repro. I'm sorry for the unnecessary confusion.