folke / edgy.nvim

Easily create and manage predefined window layouts, bringing a new edge to your workflow
Apache License 2.0
783 stars 14 forks source link

bug: Failed to layout windows #70

Closed sadguitarius closed 4 months ago

sadguitarius commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.10.0-dev-2619+gc52dfb6e8

Operating system/version

Windows 11

Describe the bug

When opening Neo-Tree (or NvimTree as well), switching to a new tab, opening another Neo-Tree window there, then switching back to the original tab, I get this error:

...AppData/Local/nvim-data/lazy/edgy.nvim/lua/edgy/util.lua:70: ...Data/Local/nvim-data/lazy/edgy.nvim/lua/edgy/edgebar.lua:207: Edgy: Failed to layout windows.
Vim:E957: Invalid window number
{
  last = "neo-tree",
  win = "edgy"
}

The error repeats with identical notifications forever and I have to quit out of Neovim. I just tried this with a basic setup of only Lazy, Neo-Tree, and Edgy with no additional configuration other than the config described on the Edgy git page, and I get the same behavior. I also checked the non-nightly build of Neovim and I'm getting the same thing. This only seems to happen when there are multiple Neo-Tree windows in the edgebar config, but I'm also getting the problem with Nvim-Tree and only a single Nvim-Tree window in the edgebar. I'm assuming this is a bug since I just copied the config from Github. Thank you and I'm otherwise loving this plugin!

Steps To Reproduce

  1. open Neo-Tree
  2. switch to a new tab
  3. open Neo-Tree there without closing Neo-Tree in the first tab
  4. switch back to the original tab

Expected Behavior

Neovim is not flooded with error notifications

Repro

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- Example using a list of specs with the default options
vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
vim.g.maplocalleader = "\\" -- Same for `maplocalleader`

require("lazy").setup({
{
    "nvim-neo-tree/neo-tree.nvim",
    branch = "v3.x",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
      "MunifTanjim/nui.nvim",
      -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
    }
},
{
  "folke/edgy.nvim",
  event = "VeryLazy",
  init = function()
    vim.opt.laststatus = 3
    vim.opt.splitkeep = "screen"
  end,
  opts = {
    left = {
      -- Neo-tree filesystem always takes half the screen height
      {
        title = "Neo-Tree",
        ft = "neo-tree",
        filter = function(buf)
          return vim.b[buf].neo_tree_source == "filesystem"
        end,
        size = { height = 0.5 },
      },
      {
        title = "Neo-Tree Git",
        ft = "neo-tree",
        filter = function(buf)
          return vim.b[buf].neo_tree_source == "git_status"
        end,
        pinned = true,
        open = "Neotree position=right git_status",
      },
      {
        title = "Neo-Tree Buffers",
        ft = "neo-tree",
        filter = function(buf)
          return vim.b[buf].neo_tree_source == "buffers"
        end,
        pinned = true,
        open = "Neotree position=top buffers",
      },
      -- any other neo-tree windows
      "neo-tree",
    },
  },
}
})
sadguitarius commented 4 months ago

Update: if I remove the Git panel from the above config and change the Buffers command to "Neotree position=right buffers", I don't get the error, so it looks like it could somehow be related to window resize callbacks.

sadguitarius commented 4 months ago

Recent updates to Neo-Tree seem to have fixed this as far as I can tell, so I'm closing the issue.