Skip to content

nvim-tree does not open after an in-place open with eject=false #2343

@usachev63

Description

@usachev63

Description

In #2341 I introduced a bug which happens only with eject = false option. Turns out, when making an in-place open with eject = false, the window, in which nvim-tree buffer is overridden with a new file, is still considered a nvim-tree window. Thus, when we try to open nvim-tree, we have view.is_visible == true an the tree is not opened.

I figured out the fix and will provide PR very soon. The issue is to put a clean room example in history.

Neovim version

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Linux 5.16.15-051615-generic

nvim-tree version

master

Clean room replication

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=./nvt-min/site]]
local package_root = "./nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    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

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {
    actions = {
      open_file = {
        eject = false,
      }
    }
  }
end

Steps to reproduce

  1. nvim -nu /tmp/nvt-min.lua
  2. :NvimTreeOpen
  3. :e nvt-min.lua
  4. :NvimTreeOpen

Expected behavior

The nvim-tree window opens.

Actual behavior

Nothing happens: nvim-tree window does not open.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions