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

[Bug]: Clicking in nvim window with legendary picker open breaks legendary #447

Closed
1 task done
WizardStark opened this issue Apr 16, 2024 · 6 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@WizardStark
Copy link

Similar Issues

  • Before filing, I have searched for similar issues.

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

Steps to Reproduce

  1. Open finder
  2. Triple click anywhere outside finder window
  3. Try to open finder again

Expected Behavior

Finder opens as normal

Actual Behavior

No finder window appears, although legendary logs report normal behaviour.

Minimal Configuration to Reproduce

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)

-- install plugins
local plugins = {
	-- do not remove the colorscheme! it makes testing nicer
	"folke/tokyonight.nvim",
	{
		"mrjones2014/legendary.nvim",
		dependencies = {
			{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
			"stevearc/dressing.nvim",
		},
	},
}

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

require("dressing").setup()

require("legendary").setup({
	-- add any options here
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme! it makes testing nicer
vim.cmd([[colorscheme tokyonight]])

Output from :LegendaryLog

:LegendaryLog output (click to expand)
[Tue 16 Apr 09:23:03 2024][legendary.nvim] Took 2.026875 ms to filter items in context.
[Tue 16 Apr 09:23:03 2024][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled.
[Tue 16 Apr 09:22:57 2024][legendary.nvim] Took 2.055083 ms to filter items in context.
[Tue 16 Apr 09:22:57 2024][legendary.nvim] Config.sort.frecency is enabled, but sqlite is not available or database could not be opened, frecency is automatically disabled.
[Tue 16 Apr 09:22:54 2024][legendary.nvim] setup() parsed and applied all configuration.


The second call here at 09:23:03 did not open any finder

Additional Details and/or Screenshots

Triple clicking may seem excessive - in my own config though it is only a single click (which often occurs when just refocusing the nvim window).

I also find this very strange as any telescope window handles this gracefully, and legendary just uses the vim.ui.select implementation of your choice.

@WizardStark WizardStark added the bug Something isn't working label Apr 16, 2024
@mrjones2014
Copy link
Owner

Interesting, I am able to reproduce, and weirdly, after adding some debug logs, it is executing properly all the way up to the vim.ui.select line (I added a debug line directly above vim.ui.select which does run) and then it appears that vim.ui.select just... does nothing?

vim.ui.select(items, {

@mrjones2014
Copy link
Owner

Possibly Neovim bug? Let's see if we can reproduce with a different vim.ui.select handler like mini.pick or fzf-lua

@WizardStark
Copy link
Author

Using mini.pick or fzf-lua I am not able to reproduce this behaviour - the window opened by either plugin closes as expected when clicking outside of it.

Super strange that this only happens with Telescope + legendary, I tried all builtin telescope pickers and was not able to break it.

minimal init.lua for swapping between all 3:

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)

-- install plugins
local plugins = {
	-- do not remove the colorscheme! it makes testing nicer
	"folke/tokyonight.nvim",
	{
		"mrjones2014/legendary.nvim",
		dependencies = {
			-- {
			-- 	"echasnovski/mini.pick",
			-- 	version = "*",
			-- 	config = function()
			-- 		vim.ui.select = require("mini.pick").ui_select
			-- 	end,
			-- },
			-- {
			-- 	"ibhagwan/fzf-lua",
			-- 	config = function()
			-- 		require("fzf-lua").register_ui_select()
			-- 	end,
			-- },
			{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
			{ "stevearc/dressing.nvim", opts = {} },
		},
	},
	-- add any other pugins here
}

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

require("legendary").setup({
	-- add any options here
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme! it makes testing nicer
vim.cmd([[colorscheme tokyonight]])

@WizardStark
Copy link
Author

Confirmed that this is a bug in the dressing code, at least for the telescope select implementation.

Any logging in this method is hit while the legendary select ui is functioning as normal, but is absent after breaking.

@WizardStark
Copy link
Author

Just for interests sake I also used fzf-lua + dressing, which does not break - so narrowed down to the dressing telescope select implementation.

@WizardStark
Copy link
Author

Created issue stevearc/dressing.nvim#150, feel free to close this!

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

No branches or pull requests

2 participants