stevearc / dressing.nvim

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

Dressing window remains open after entering command line window #99

Closed smjonas closed 1 year ago

smjonas commented 1 year ago

Describe the bug Problem: I want to close dressing's vim.ui.input window while the command window is open to solve this issue: https://github.com/smjonas/inc-rename.nvim/issues/37. I would expect the window to be automatically closed once command line mode is entered (since that exits dressing's buffer and should trigger the BufLeave autocommand here). Also note that after running the below DressingBug command, calling require("dressing.input").close() has no effect and the window remains in an "orphaned" state.

System information

require("dressing").setup{}

To Reproduce Steps to reproduce the behavior:

  1. Copy the following user command to your config and source the file:
    vim.api.nvim_create_user_command("DressingBug", function()
    vim.ui.input("Test", function() end)
    -- Exit insert mode and enter command line mode
    vim.cmd.stopinsert()
    vim.api.nvim_feedkeys(":", "n", false)
    -- Enter cmdline window
    local ctrl_f = vim.api.nvim_replace_termcodes("<C-f>", true, false, true)
    vim.api.nvim_feedkeys(ctrl_f, "n", true)
    -- Leave cmdline window
    vim.schedule(function()
    vim.cmd("q")
    end)
    end, {})
  2. Run the command
  3. Exit the dressing window (e.g. with <C-w>w) Notice that the window was exited but remains open (see screenshot).

Running require("dressing.input").close() also has no effect.

Screenshots image This shows that the cursor is placed outside of the input window which should not be possible.

stevearc commented 1 year ago

I put in a fix for this. It seems to work from my testing, but I unfortunately couldn't get a repro to happen in a unit test. LMK if this works for you

smjonas commented 1 year ago

Thanks for the quick fix, your patch seems to work fine!