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

'<c-w>T' causes incorrect buffer list #25

Open
swerling opened this issue Mar 27, 2024 · 1 comment
Open

'<c-w>T' causes incorrect buffer list #25

swerling opened this issue Mar 27, 2024 · 1 comment

Comments

@swerling
Copy link

The buffer list gets out of sync if you move a buffer to a new tab using <c-w>T.

To recreate:

  1. Split a tab and load a file into each split, so that buffers contain 2 different files.
  • Eg open file a, :e a.txt -> split, <c-w>v -> open file b, :e b.txt
  1. Move one of the files to a new tab with <c-w>T
  2. Go back to the original tab
  3. :buffers

When you do the 3 steps above, you'll see that both files are still in scope on the first tab. The first file should have been moved to the second tab. Furthermore, trying to delete the buffer from the old tab using bDel removes it both from the original tab but also from the new one.

@tiagovla
Copy link
Owner

tiagovla commented Apr 5, 2024

Would something like this work?

vim.keymap.set({ "n", "o", "x" }, "<c-w>T", function()
    local old_tab = vim.api.nvim_get_current_tabpage()
    local buf = vim.api.nvim_get_current_buf()
    vim.cmd [[execute "normal! \<C-W>T"]]
    local new_tab = vim.api.nvim_get_current_tabpage()
    if old_tab ~= new_tab then
        local cache = require("scope.core").cache
        cache[old_tab] = vim.tbl_filter(function(e)
            return e ~= buf
        end, cache[old_tab])
    end
end, { desc = "move into new tab", remap = false })

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

2 participants