Closed 3Xpl0it3r closed 1 year ago
Sorry, that's just not how this code works. vim.fn.input
is synchronous and blocking, so you are guaranteed that all code following that call will run after the user has completed the input. vim.ui.input
, on the other hand, is asynchronous. Calling it kicks off the input request to the user (by opening a floating window), but the code following that function call will run more or less immediately. If you want to know when the user has completed the input, that's what the callback is for.
The benefits of async are that you can perform operations without completely freezing vim's UI. The downside is that once you have one async function, everything above it in the stack also has to be async.
The way to structure your code above to run one after another is like this:
vim.ui.input({ prompt = "hehe" }, function(input)
-- Do something here
vim.ui.select(crate_fuz_list, { prompt = "select one" }, function(crate_choice)
-- Do something else
end)
end)
Describe the bug Is there any way to block vim.ui.input to wait user complete input, then there more than one vim.ui.xxxx in lua. In this case first vim.ui.input will skip user input directory step into vim.wait code and finally step into vim.ui.select
System information