Skip to content

Problem with opening new files when :help window is opened #3001

@KriBielinski

Description

@KriBielinski

Description

While opening and closing files and :help buffer in a specific order, after then opening a new file using nvim-tree, the new file is open in a split window instead of replacing the :help buffer.
The problem can be replicated using just the standard configuration.

Neovim version

NVIM v0.11.0-dev-1079+g7bf3a616e1                                                                                                   
Build type: Release                                                                                                                 
LuaJIT 2.1.1727870382

Operating system and version

Distro: Linux Mint 21 Vanessa, base: Ubuntu 22.04 jammy

Windows variant

No response

nvim-tree version

28eac28

Clean room replication

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

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",
      "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({})
end

-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.
-- Requires diagnostics.enable = true in setup.
--[[
vim.api.nvim_create_autocmd("FileType", {
  pattern = "lua",
  callback = function()
    vim.lsp.start {
      name = "my-luals",
      cmd = { "lua-language-server" },
      root_dir = vim.loop.cwd(),
    }
  end,
})
]]

Steps to reproduce

  1. nvim -nu /tmp/nvt-min.lua to open Neovim
  2. :NvimTreeOpen to open nvim-tree. It will appear in a split on the left.
  3. Navigate to any file inside of nvim-tree and than press Enter to open it. The file will appear on the window to the right.
  4. :help to open the help window. It should appear in a split window next to the opened file.
  5. Navigate to the window with the file opened in step 3 (using <C-w>+h/j/k/l) and close that window with :q
  6. Navigate to nvim-tree window (using <C-w>+h/j/k/l)
  7. Open any file (doesn't have to be the same as before) as described in step 3

Expected behavior

The newly opened file should replace the :help buffer (as it would do with any other buffer) but instead the new file openes in a vertical split next to the :help window. Also if instead of opening the file in step 7 you instead press <C-x> to attempt to open the file in horizontal split, the file still opens in vertical split.

Actual behavior

The newly opened file opens in a vertical split (either when opening using Enter or <C-x>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions