Skip to content

Commit

Permalink
fix: work around neovim open_win bug (#15)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stevearc committed Jan 18, 2022
1 parent 74c953a commit 3f23266
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lua/dressing/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ M.trigger_completion = function()
end

setmetatable(M, {
__call = function(_, opts, on_confirm)
-- use schedule_wrap to avoid a bug when vim opens
-- (see https://github.com/stevearc/dressing.nvim/issues/15)
__call = vim.schedule_wrap(function(_, opts, on_confirm)
vim.validate({
on_confirm = { on_confirm, "function", false },
})
Expand Down Expand Up @@ -284,7 +286,7 @@ setmetatable(M, {
vim.cmd("startinsert!")
close_completion_window()
M.highlight()
end,
end),
})

return M
6 changes: 4 additions & 2 deletions lua/dressing/select/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ local function get_backend(config)
return require("dressing.select.builtin"), "builtin"
end

return function(items, opts, on_choice)
-- use schedule_wrap to avoid a bug when vim opens
-- (see https://github.com/stevearc/dressing.nvim/issues/15)
return vim.schedule_wrap(function(items, opts, on_choice)
vim.validate({
items = {
items,
Expand Down Expand Up @@ -45,4 +47,4 @@ return function(items, opts, on_choice)

local backend, name = get_backend(config)
backend.select(config[name], items, opts, on_choice)
end
end)

0 comments on commit 3f23266

Please sign in to comment.