stevearc / dressing.nvim

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

Misbehaviour when using with autocommands #15

Closed Penaz91 closed 2 years ago

Penaz91 commented 2 years ago

Greetings, thanks for making this plugin.

I've been trying to port one of my plugins from VimScript to Lua using vim.ui.select and I came across the following issue: when I use any floating window via vim.ui + Dressing coming from an autocommand (In this specific case BufNewFile) the floating window appears but the document is actually selected and insert mode is active.

I managed to reproduce it with the following config (besides plenary, telescope and dressing as installed plugins):

lua << EOF
function test()
   vim.ui.select({"echo 'Hi'"}, {}, function(item, _) if item then vim.cmd(item) end end)
end

vim.cmd([[autocmd BufNewFile * lua test()]])
EOF

I'm sorry if something I wrote is wrong, I'm not an expert in either VimScript or Lua. Seems that the standard vim.ui works correctly, as long as i set shortmess-=F (which doesn't help with dressing).

I'm ready to answer any question, if needed. Thank you in advance!

stevearc commented 2 years ago

I am not able to repro this with either telescope or the built-in select UI.

https://user-images.githubusercontent.com/506791/149847165-aa73ee75-f21b-4d14-b976-2115a9c824be.mp4

It's possible that there is some difference in configuration between our setups. Can you try this with an absolute minimal install, no other plugins and no other config that could interfere? Also, what version of Neovim are you using?

Penaz91 commented 2 years ago

Thank you kindly for your response, and sorry for missing some details. Your video made me think a bit and I narrowed the issue: it seems that the misbehaviour happens when I trigger BufNewFile while opening Nvim; if I use the :e command, everything works correctly.

I'm using NeoVim 0.6.1 (I did a :version command in my screencast), for this quick screencast I'm using my everyday configuration due to time constraints, I'll try to get to you with a minimal VimRC after work.

https://user-images.githubusercontent.com/6682630/149891833-76e17f80-d9dd-4885-a14b-3091239e07a3.mp4

Hopefully, in the meantime, this helps narrowing the issue a tiny bit.

Thank you again.

stevearc commented 2 years ago

I can repro it now, thanks! This looks like a bug in neovim itself https://github.com/neovim/neovim/issues/12295

I've added a workaround that should eliminate the issue

Penaz91 commented 2 years ago

The workaround seems to be working well. Thank you very much.

I'll report back if more issues arise.