Shougo / ddu-ui-filer

File listing UI for ddu.vim
MIT License
55 stars 8 forks source link

preview window doesn't redraw in `redraw` action #35

Closed kamecha closed 10 months ago

kamecha commented 10 months ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

SSIA

Expected

ddu window and preview window are both updated and redraw.

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

vim.opt.rtp:append("~/.cache/dein/nvim/repos/github.com/vim-denops/denops.vim")
vim.opt.rtp:append("~/.cache/dein/nvim/repos/github.com/Shougo/ddu.vim")
vim.opt.rtp:append("~/.cache/dein/nvim/repos/github.com/Shougo/ddu-ui-filer")
vim.opt.rtp:append("~/.cache/dein/nvim/repos/github.com/Shougo/ddu-source-file")
vim.opt.rtp:append("~/.cache/dein/nvim/repos/github.com/Shougo/ddu-kind-file")

local function set_filer_layout()
    vim.fn["ddu#custom#patch_local"]("default", {
        uiParams = {
            filer = {
                split = "floating",
                winRow = 1,
                winCol = 1,
                winWidth = "&columns / 2",
                winHeight = "&lines",
                previewFloating = true,
                previewRow = 1,
                previewCol = "&columns / 2",
                previewWidth = "&columns / 2",
                previewHeight = "&lines",
            }
        }
    })
end

set_filer_layout()

local function update_ui_layout()
    local currentOptions = vim.fn["ddu#custom#get_current"]()
    if vim.tbl_isempty(currentOptions) then
        return
    end
    local updatedLocalOptions = vim.fn["ddu#custom#get_local"]()
    if vim.tbl_isempty(updatedLocalOptions) then
        return
    end
    vim.fn["ddu#ui#do_action"]('updateOptions', updatedLocalOptions[currentOptions["name"]])
    vim.fn["ddu#ui#do_action"]('redraw', { method = "uiRedraw" })
end

vim.api.nvim_create_autocmd("VimResized", {
    pattern = "*",
    callback = function()
        set_filer_layout()
        update_ui_layout()
    end
})

vim.keymap.set('n', '<Space>e', function ()
    vim.fn["ddu#start"]({
        ui = "filer",
        sources = { "file" }
    })
end)

vim.api.nvim_create_autocmd("FileType", {
    pattern = "ddu-filer",
    callback = function()
        vim.keymap.set('n', 'p', function ()
            vim.fn["ddu#ui#do_action"]('preview')
        end)
        vim.keymap.set('n', 'q', function ()
            vim.fn["ddu#ui#do_action"]('quit')
        end)
    end
})

How to reproduce the problem from neovim/Vim startup (Required!)

  1. type <Space> e to start ddu
  2. type p on ddu window to start preview
  3. change the vim window size to fire VimResized autocmd
  4. the preview window size does not changed...

Screenshot (if possible)

hoge

Upload the log messages by :redir and :message (if errored)

Shougo commented 10 months ago

Please don't use Lua. I don't want to debug Lua script.

Shougo commented 10 months ago

Sorry. Current preview feature does not support redraw. If you want to redraw preview window, you need to both UI actions closePreviewWindow and preview again.