Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking outside telescope select window breaks all vim.ui.select actions #150

Open
WizardStark opened this issue Apr 17, 2024 · 1 comment · May be fixed by nvim-telescope/telescope.nvim#3182
Assignees
Labels
bug Something isn't working

Comments

@WizardStark
Copy link

WizardStark commented Apr 17, 2024

Describe the bug
Opening a vim.ui.select window using the telescope backend and then clicking outside the popup breaks all subsequent vim.ui.select calls.

See mrjones2014/legendary.nvim#447 for original discovery of this issue and additional context

System information

  • OS: [windows/linux/mac] - all three
  • Neovim version:
$ nvim --version 
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1710088188

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

  • Is this related to a specific vim.ui.select backend? If so, which one?
    • Telescope
  • Dressing config:
    • Provided in minimal init.lua below

To Reproduce
Steps to reproduce the behavior:

  1. vim.ui.select({ "apple", "banana" }, {}, function(item) vim.print(item) end) - mapped to <space>a for convenience
  2. triple click outside the window
  3. <space>a again, or call vim.ui.select

If possible, provide a minimal file that will trigger the issue (see
tests/manual
for examples of short ways to call vim.ui.*):

vim.g.mapleader = " "
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
	"folke/tokyonight.nvim",
	{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
	{ "stevearc/dressing.nvim", opts = {} },
}

require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.keymap.set("n", "<leader>a", function()
	vim.ui.select({ "apple", "banana" }, {}, function(item)
		vim.print(item)
	end)
end)

vim.opt.termguicolors = true
vim.cmd([[colorscheme tokyonight]])

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@emmanueltouzery
Copy link
Contributor

dressing needs to do something when the telescope picker is closed for any reason. I really tried to find a way to achieve that with telescope, and just couldn't. I have now opened them a PR to add the feature (I guess worst-case they'll say how to achieve that otherwise):
nvim-telescope/telescope.nvim#3182

With this in telescope, I confirmed that putting this in the telescope.lua file in dressing at line ~96 fixes the issue:

  vim.api.nvim_create_autocmd("User", {
    pattern = "TelescopePickerClose",
    callback = function(args)
      on_choice(nil, nil)
    end,
    once = true,
  })

I'll followup here when the telescope part of the issue is resolved one way or another.

emmanueltouzery added a commit to emmanueltouzery/dressing.nvim that referenced this issue Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants