Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Buffer with this name already exists after manually closing neo-tree #1415

Closed
3 tasks done
idanarye opened this issue Mar 25, 2024 · 4 comments · Fixed by #1433
Closed
3 tasks done

BUG: Buffer with this name already exists after manually closing neo-tree #1415

idanarye opened this issue Mar 25, 2024 · 4 comments · Fixed by #1433
Labels
bug Something isn't working

Comments

@idanarye
Copy link

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

0.9.5

Operating System / Version

Arch Linux 6.7.0-arch3-1

Describe the Bug

This looks similar to #1365, but since I don't use sessions (the discussion there is mostly about how fix it by fixing session management with a new )auto_restore_session_experimental = true setting) and since I've only started experiencing this a couple of days ago (that ticket is almost a month old), I suspect it may be a different bug.

When closing the Neo-tree panel using Vim commands (like :quit or like running :only from another window), another attempt to open the Neo-tree panel will result in a Buffer with this name already exists error.

Note that when I close the panel using Neo-tree (e.g. - by hitting q inside it) this problem does not occur.

Screenshots, Traceback

[Neo-tree ERROR] debounce  filesystem_navigate  error:  ...e-bug/plugins/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:1036: Vim:E95: Buffer with this name already exists

Steps to Reproduce

  1. Run :Neotree to open the Neo-tree panel.
  2. Run :close inside the Neo-tree panel to close it (don't use any of Neo-tree's shortcuts/commands for closing the panel - use Vim's window management commands)
  3. Run :Neotree again.

Expected Behavior

I'd expect the Neo-tree panel to just open again.

Your Configuration

local lazypath = "/tmp/reproduce-bug/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)

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
        }
    }
}, {
    root = "/tmp/reproduce-bug/plugins",
})
@idanarye idanarye added the bug Something isn't working label Mar 25, 2024
@idanarye
Copy link
Author

Note that I've managed to workaround this problem by adding this event handle:

{
    event = 'neo_tree_buffer_leave',
    handler = function()
        local shown_buffers = {}
        for _, win in ipairs(vim.api.nvim_list_wins()) do
            shown_buffers[vim.api.nvim_win_get_buf(win)] = true
        end
        for _, buf in ipairs(vim.api.nvim_list_bufs()) do
            if not shown_buffers[buf] and vim.api.nvim_buf_get_option(buf, 'buftype') == 'nofile' and vim.api.nvim_buf_get_option(buf, 'filetype') == 'neo-tree' then
                vim.api.nvim_buf_delete(buf, {})
            end
        end
    end,
},

But this, of course, is an ugly hack.

@nmfirdausw
Copy link

@idanarye Its working, haha... Will use this for a while

@pysan3 pysan3 changed the title BUG: BUG: Buffer with this name already exists after manually closing neo-tree Mar 27, 2024
pysan3 added a commit to pysan3/neo-tree.nvim that referenced this issue Mar 27, 2024
@chaozwn
Copy link

chaozwn commented Mar 28, 2024

Regarding how to reproduce the issue: <C-w>o, then open neo-tree.

@rodhash
Copy link

rodhash commented Apr 8, 2024

Regarding how to reproduce the issue: <C-w>o, then open neo-tree.

+1 same here, error persists even after adding the above function into event_handlers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants