Skip to content

Stack trace when toggling with multiple tabs #1184

@igorlfs

Description

@igorlfs

Description

When opening nvim-tree in more than one tab, closing nvim-tree's split moves you to the next tab with nvim-tree open (as opposed to leaving you in the same tab as you were before) and subsequently closing nvim-tree in this tab throws a stack trace.

Neovim version

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Linux 5.17.3-artix1-1

nvim-tree version

ebf73f0

Steps to reproduce

  1. nvim -nu /tmp/nvt-min.lua
  2. :NvimTreeOpen
  3. :tabnew
  4. :NvimTreeOpen
  5. return to the first tab, eg gt (this is only necessary to reproduce the "closing nvim-tree's window moves you to the next tab with nvim-tree open", as the stack trace is thrown regardless)
  6. :NvimTreeClose - at this stage you should have been moved to the second tab
  7. :NvimTreeToggle results in
E5108: Error executing lua ...e/pack/packer/start/nvim-tree.lua/lua/nvim-tree/view.lua:81: Vim:E95: Buffer with this name already exists                                                                    
stack traceback:
        [C]: in function 'nvim_buf_set_name'
        ...e/pack/packer/start/nvim-tree.lua/lua/nvim-tree/view.lua:81: in function 'create_buffer'
        ...e/pack/packer/start/nvim-tree.lua/lua/nvim-tree/view.lua:190: in function 'open'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/lib.lua:97: in function 'open_view_and_draw'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/lib.lua:123: in function 'open'
        ...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:47: in function 'open'
        ...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:31: in function 'toggle'
        [string ":lua"]:1: in main chunk

Also, if in step 7 you try to run :NvimTreeClose instead, nvim-tree's split won't be closed and no error message will be thrown.

Expected behavior

Nvim-tree should close normally when used with multiple tabs.

Actual behavior

Either an error is thrown or nvim-tree isn't closed at all.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "kyazdani42/nvim-tree.lua",
      "kyazdani42/nvim-web-devicons",
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

_G.setup = function()
  require("nvim-tree").setup {}
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions