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] When closing dbee window, previous tab is changed to empty buffer #120

Open
Rizhiy opened this issue Jun 9, 2024 · 3 comments
Open

Comments

@Rizhiy
Copy link

Rizhiy commented Jun 9, 2024

Steps to reproduce:

  1. Open a file with vim
  2. Create new tab (:tabnew)
  3. Open dbee in new tab
  4. Close dbee (e.g. with :q)

Expected outcome:
All relevant buffers are closed correctly, and you are either left with whatever was open before you opened db or the other tab.

Actual outcome:
tab with dbee is closed, the first tab is change to a single empty buffer (even if there were multiple splits open before).

@Rizhiy Rizhiy changed the title [BUG} When closing dbee window, previous tab is changed to empty buffer [BUG] When closing dbee window, previous tab is changed to empty buffer Jun 9, 2024
@yofriadi
Copy link

yofriadi commented Jul 2, 2024

I have the same problem, when I open more than 1 tab, it closed any last tab I have
attached screen record of the problem

Screen.Recording.2024-07-02.222059.mp4

I have tab 1,2,3 then when I open nvim-dbee and close it,
tab 3 disappeared and move all tab 3 buffer to tab 2.

also posting Discord discussion link with AstroNvim creator that think there is bad tab management things and it's close function
https://discord.com/channels/939594913560031363/1257715805743747216/1257715805743747216

@mehalter
Copy link

mehalter commented Jul 2, 2024

Here is a reproducing minimal configuration:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    {
        "kndndrj/nvim-dbee",
        dependencies = {
            "MunifTanjim/nui.nvim",
        },
        build = function()
            -- Install tries to automatically detect the install method.
            -- if it fails, try calling it with one of these parameters:
            --    "curl", "wget", "bitsadmin", "go"
            require("dbee").install()
        end,
        config = function()
            require("dbee").setup(--[[optional config]])
        end,
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

Steps to Reproduce

  1. Save the above in a folder named repro.lua
  2. rm -rf .repro, make sure to clean any previous repro environment (fine if this errors, it means no previous environment)
  3. nvim -u repro.lua, start up neovim with the repro.lua file and let it install
  4. q, close out of Lazy plugin manager
  5. :e repro.lua, open a file
  6. :tabnew, make a new tab (see the new tab in the tabline on the top
  7. i, go into insert mode
  8. Hello, World!, insert some text
  9. <Esc>, leave insert mode
  10. :lua require("dbee").open(), open the dbee interface
  11. :lua require("dbee").close(), close dbee
  12. see that we are now down to a single tab and our 1st tab is closed leaving us with only our Hello, World!

@asmodeus812
Copy link

asmodeus812 commented Aug 10, 2024

Same issue, overall dbee is trying to restore the old layout, but defaulting to restoring the layout and such is probably assuming too much. There is a small work around you can override the default close function like so

    local layouts = require("dbee.layouts")
    function layouts.Default:close()
        for _, win in ipairs(self.windows) do
            pcall(vim.api.nvim_win_close, win, false)
        end
        self.is_opened = false
    end

OR

    local tools = require("dbee.layouts.tools")
    local noop = function() return nil end
    tools.save = noop
    tools.restore = noop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants