stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.7k stars 32 forks source link

Error running vim.ui.select in the fzf_lua backend the first time since nvim startup #64

Closed Penaz91 closed 1 year ago

Penaz91 commented 1 year ago

Describe the bug The first time I use vim.ui.select after starting Nvim, I get an error similar to the following:

Error executing vim.schedule lua callback: ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: attempt to call a nil value                                              
stack traceback:
        ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: in function 'select'
        .../packer/start/dressing.nvim/lua/dressing/select/init.lua:63: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

This was triggered by using the :lua vim.ui.select({1,2,3}, {}, function(opt)end) command. Running the command again will work correctly

System information

To Reproduce Steps to reproduce the behavior:

  1. Start Nvim
  2. Use the following command :lua vim.ui.select({1,2,3}, {}, function(opt)end)
  3. Dressing crashes
  4. If you use the same command again, the command goes through correctly

Additional context I'm using the following lua plugin related to FZF:

illia-danko commented 1 year ago

@Penaz91 @stevearc https://github.com/stevearc/dressing.nvim/pull/65 related

stevearc commented 1 year ago

This is a bug in fzf-lua. Fixed here: https://github.com/ibhagwan/fzf-lua/pull/522

ibhagwan commented 1 year ago

This is a bug in fzf-lua. Fixed here: ibhagwan/fzf-lua#522

Merged @stevearc’s PR, apologize for the mess.

stevearc commented 1 year ago

@ibhagwan no worries! Bugs happen :)

ibhagwan commented 1 year ago

@ibhagwan no worries! Bugs happen :)

I didn’t know anyone used fzf_wrap like this (directly by ref from require'fzf-lua'), I guess this was written before the introduction of the fzf_exec API which would be the better (and clearer way) to write this.

ibhagwan commented 1 year ago

Let me know if you wish, I can submit a PR to convert the current fzf_wrap code to fzf_exec.

stevearc commented 1 year ago

Would love a PR to convert it to the best-practice API!

ibhagwan commented 1 year ago

https://github.com/stevearc/dressing.nvim/pull/67

Also took the liberty to improve upon the item number extraction using a lua regex :-)

Penaz91 commented 1 year ago

Updated both fzf-lua and dressing to the latest commit, everything seems to be working perfectly.

It's great seeing such tight cooperation between different repository owners.

Thank you for everything, feel free to close!