Skip to content

Opening a second file is creating a new window #1214

Closed
@be-ndee

Description

@be-ndee

Description

I have disabled the window_picker. And when I open two files, then it creates a new window for both of the files. So I end up having 3 windows: nvim-tree, file A and file B. Any other file will be opened in the window of file B.

I've tried to fix this bug, but I did not understand the behavior 100%. What I noticed, is that the _prevent_buffer_override() function is called when opening file B, but not while opening file A. And then the line a.nvim_win_close(curwin, { force = true }) is called. But when I look at the window numbers which are used, everything looks good...

Maybe you have a clue or can give me a hint when the _prevent_buffer_override should be called.

Neovim version

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

Operating system and version

Linux 20.04.1-Ubuntu

nvim-tree version

master

Steps to reproduce

IMPORTANT: window_picker must be disabled

  1. Open neovim
  2. Open a file with pressing enter in nvim-tree
  3. Cursor should be in a new buffer with the new file
  4. Navigate the cursor to the nvim-tree
  5. Open a different file with pressing enter in nvim-tree

Expected behavior

The second file should not create a third window. It should replace the file in the second window:

Windows:

1. nvim-tree
2. file B

Buffers:

1. nvim-tree
2. file A
3. file B

Actual behavior

The second file is creating a third window:

Windows:

1. nvim-tree
2. file A
3. file B

Buffers:

1. nvim-tree
2. file A
4. file B

Minimal config

require'nvim-tree'.setup {
  disable_netrw = true,
  view = {
    width = 40,
    hide_root_folder = true,
    relativenumber = true,
  },
  actions = {
    open_file = {
      resize_window = true,
      window_picker = {
        enable = false,
      }
    }
  }
}

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