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

Misbehaviour when using with autocommands #15

Closed
Penaz91 opened this issue Jan 17, 2022 · 4 comments
Closed

Misbehaviour when using with autocommands #15

Penaz91 opened this issue Jan 17, 2022 · 4 comments

Comments

@Penaz91
Copy link

Penaz91 commented Jan 17, 2022

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!

@Penaz91 Penaz91 changed the title Misbehaviour when using autocommands Misbehaviour when using with autocommands Jan 17, 2022
@stevearc
Copy link
Owner

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

2022-01-17.15-25-05.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
Copy link
Author

Penaz91 commented Jan 18, 2022

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.

vid-2022-01-18-083250.mp4

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

Thank you again.

stevearc added a commit that referenced this issue Jan 18, 2022
Per neovim/neovim#12295, it seems we cannot
open *and* enter a floating window during vim startup. To work around
that, we use vim.schedule_wrap() on the entrypoints. This should not
produce any noticeable effect in functionality.
@stevearc
Copy link
Owner

I can repro it now, thanks! This looks like a bug in neovim itself neovim/neovim#12295

I've added a workaround that should eliminate the issue

@Penaz91
Copy link
Author

Penaz91 commented Jan 19, 2022

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

I'll report back if more issues arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants