mikavilpas / yazi.nvim

A Neovim Plugin for the yazi terminal file manager
MIT License
569 stars 19 forks source link

previewing file causes all 3 yazi columns to shift left about 20px #554

Closed kenbankspeng closed 6 days ago

kenbankspeng commented 2 weeks ago

Reproduce:

  1. Open yazi within Neovim
  2. Before natigating, observe that alignment of 3 yazi columns is as expected.
  3. Scroll down to select/preview a file
  4. Observe that the previewed file causes all 3 yazi columns to shift left about 20 px or so, causing the content of the first column to be slightly clipped / hidden.

Yazi does not have this issue outside of nvim.

My yazi column ratio: 3, 3, 6 NVIM v0.10.2 "yazi.nvim": { "branch": "main", "commit": "caaebf12464d80d479be497c97d92c1c71b16e94" }

kenbankspeng commented 2 weeks ago

My yazi.nvim config

return {
  {
    'mikavilpas/yazi.nvim',
    event = 'VeryLazy',
    keys = {
      { '<leader>ys', '<cmd>Yazi<cr>', desc = 'yazi same' },
      { '<leader>yr', '<cmd>Yazi cwd<cr>', desc = 'yazi root' },
      { '<leader><space>', '<cmd>Yazi toggle<cr>', desc = 'yazi toggle' },
    },
    opts = { 
      -- an upcoming optional feature. See
      -- https://github.com/mikavilpas/yazi.nvim/pull/152
      use_ya_for_events_reading = true,

      -- an upcoming optional feature
      use_yazi_client_id_flag = true,

      -- the floating window scaling factor. 1 means 100%, 0.9 means 90%, etc.
      floating_window_scaling_factor = 1.0,

      -- the transparency of the yazi floating window (0-100). See :h winblend
      yazi_floating_window_winblend = 0,
    },
  },
}
mikavilpas commented 2 weeks ago

Could you see if you can reproduce the issue with these instructions?

https://github.com/mikavilpas/yazi.nvim/blob/main/documentation/reproducing-issues.md

kenbankspeng commented 2 weeks ago

I was not able to reproduce the issue using the minimal repro.lua.

I don't think that I can add to repro.lua until the issue occurs because it seems to be lazy itself. I completely gutted my config down to just init, lazy and yazi (no other plugins, no lazy extensions) and it still has the issue. So it seems that there is a difference between repro.lua and lazy.lua. I suspect I would need to change repro not add to it.

I can reproduce the issue with just these 3 minimal files:

init.lua

require('config.lazy')

lua/plugins/yazi.lua

return {
    {
        "mikavilpas/yazi.nvim",
        event = "VeryLazy",
        keys = {
            { ",,", "<cmd>Yazi toggle<cr>", desc = "yazi toggle" },
        },
    },
}

lua/config/lazy.lua (as per lazy.vim instructions)

local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
      { out, 'WarningMsg' },
      { '\nPress any key to exit...' },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  spec = {
    -- add LazyVim and import its plugins
    { 'LazyVim/LazyVim', import = 'lazyvim.plugins' },
    -- import/override with your plugins
    { import = 'plugins' },
  },
  defaults = {
    -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
    -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
    lazy = false,
    -- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
    -- have outdated releases, which may break your Neovim install.
    version = false, -- always use the latest git commit
    -- version = "*", -- try installing the latest stable version for plugins that support semver
  },
  install = { colorscheme = { 'tokyonight', 'habamax' } },
  checker = {
    enabled = true, -- check for plugin updates periodically
    notify = false, -- notify on update
  }, -- automatically check for plugin updates
  performance = {
    rtp = {
      -- disable some rtp plugins
      disabled_plugins = {
        'gzip',
        -- "matchit",
        -- "matchparen",
        -- "netrwPlugin",
        'tarPlugin',
        'tohtml',
        'tutor',
        'zipPlugin',
      },
    },
  },
})
kenbankspeng commented 2 weeks ago

So lazy.vim uses lazy.nvim. And lazy.vim just went to the next major revison, so a lot of rework just occurred.

Also, issue only occurs if yazi is the first modal window used. If yazi is the second modal popup the issue does not occur. If yazi is toggled twice (open/close/open/close), the issue only occurs on the first toggle.

Possibly a lazy.vim change is doing this.

mikavilpas commented 2 weeks ago

Also, issue only occurs if yazi is the first modal window used. If yazi is the second modal popup the issue does not occur. If yazi is toggled twice (open/close/open/close), the issue only occurs on the first toggle.

I think I have also seen this but with lazygit instead of yazi.nvim. I even have a hack where I open a notification and immediately dismiss it to try and work around it in my config (here). It sometimes works but if I'm too fast to open lazygit, it still shifts to the left.

kenbankspeng commented 2 weeks ago

Issue observed in LazyVim v13.0.0 (commit: 5efb88f44a03d0fd8ca3801067de904aecf7e86d) Issue not observed in LazyVin v12.44.1 (commit: 73f14943bac5830905d715804ca581a91844272a)

So definitely LazyVim changes.

mikavilpas commented 2 weeks ago

I upgraded to lazyvim 13 today and now I also see this same bug. Let me know if you have any ideas how it could be fixed or worked around.

kenbankspeng commented 2 weeks ago

Raise issue against LazyVim 13.

Possible temporary workaround: on init, toggle yazi twice, if possible in some opacity = 0 hack mode.

mikavilpas commented 1 week ago

@kenbankspeng I don't seem to get this bug anymore with LazyVim v13.5.0. Can you see if you are able to reproduce it? I have done nothing so I'm thinking it might be fixed by something upstream.

kenbankspeng commented 6 days ago

I am now on LazyVim v13.5.2 and do not see the issue. Thank you.