VonHeikemen / fine-cmdline.nvim

Enter ex-commands in a nice floating input.
MIT License
445 stars 7 forks source link

fix Input props caching #14

Closed alex-popov-tech closed 2 years ago

alex-popov-tech commented 2 years ago

Hello, thank you for plugin!

I found an issue, which is when you calling setup it remembers M.Input object with all required calculations, and if screen size changed ( for me it was tmux splits ), popup config passed by user is not relevant anymore:

https://user-images.githubusercontent.com/21224705/142933682-c10fc841-df27-4013-9ea9-066f3d8471e8.mp4

so I just moved initialization of M.Input to open call to do it every time before rendering...

here is my config chunk:

            require("fine-cmdline").setup(
                {
                    popup = {
                        relative = "win",
                        position = {
                            row = "50%",
                            col = "50%"
                        },
                        size = {
                            width = "60%",
                            height = 1
                        }
                    }
                }
            )
VonHeikemen commented 2 years ago

That would break the before_mount hook.

I think it would be better to create a function to reset.

M.reset = function()
  M.setup(state.user_opts)
end

And then make an autocommand.

vim.cmd([[
    augroup fineline_commands
      autocmd!
      autocmd VimResized * lua require('fine-cmdline').reset()
    augroup END
]])
alex-popov-tech commented 2 years ago

oh yes, for before_mount i should move input initialization a bit to the top....

i've just tested your proposition, but it did not worked for me, did you tried that autocmd with tmux pane resizing & terminal window resizing?

VonHeikemen commented 2 years ago

I did.

And even before that I tested VimResized (without my code), I used these commands to setup a variable and then increment.

:lua vim.g.times = 0
:autocmd VimResized * lua vim.g.times = vim.g.times + 1

After each test I used :lua print(vim.g.times).


Anyway, if we are going this route of making a new instance might as well just delete the if at the beginning of open.