stevearc / dressing.nvim

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

Incorrect title position with `vim.ui.input` inside command preview callback #61

Closed smjonas closed 1 year ago

smjonas commented 1 year ago

Describe the bug When using vim.ui.input inside a command preview callback, the window title is not immediately positioned at the correct position.

System information

To Reproduce Steps to reproduce the behavior:

  1. Define a user command such as the following which calls vim.ui.input inside the preview callback:

    vim.api.nvim_create_user_command("X", function() end, {
    preview = function()
    vim.ui.input({}, function() end)
    end,
    nargs = 1,
    addr = "lines",
    })
  2. Type :X. Notice how the title is positioned at the top left of the screen: image

  3. Type (space). The title has now moved to the correct position: image

Additional context It seems like Nvim only executes one "step" of the window creation, while the last "step" of moving the title (which I believe is also a window) is scheduled to run later. Though I'm not exactly sure what causes this (probably somewhere in add_title_to_win).

smjonas commented 1 year ago

This seems more like an upstream issue: https://github.com/neovim/neovim/issues/20094, closing for now.

stevearc commented 1 year ago

That's unfortunate. I do have a hack in place that has fixed some of the title positioning issues https://github.com/stevearc/dressing.nvim/blob/9cdb3e0f0973447b940b35d3175dc780301de427/lua/dressing/util.lua#L104-L106

But as you say it appears to not be working when opened from a "preview" callback. I tried some other basic hacks (vim.schedule_wrap) but the issue persists. I think we may have to wait for the upstream fix :/

smjonas commented 1 year ago

Yes, it's a bit strange that redrawing is completely disabled inside the callback. I'm looking forward to zeertzjq's fix / FFI workaround :D