allow showing of buffer in a different tab if its already opened in another tab #1297

This commit is contained in:
siduck 2022-07-01 06:27:40 +05:30
parent d4c71e1472
commit 7654a1fc8c

View file

@ -39,7 +39,7 @@ autocmd("BufEnter", {
vim.t.bufs = vim.api.nvim_list_bufs() vim.t.bufs = vim.api.nvim_list_bufs()
-- thx to https://github.com/ii14 & stores buffer per tab -> table -- thx to https://github.com/ii14 & stores buffer per tab -> table
autocmd("BufAdd", { autocmd({ "BufAdd", "BufEnter" }, {
callback = function(args) callback = function(args)
if vim.t.bufs == nil then if vim.t.bufs == nil then
vim.t.bufs = { args.buf } vim.t.bufs = { args.buf }
@ -47,7 +47,7 @@ autocmd("BufAdd", {
local bufs = vim.t.bufs local bufs = vim.t.bufs
-- check for duplicates -- check for duplicates
if not vim.tbl_contains(bufs, args.buf) then if not vim.tbl_contains(bufs, args.buf) and (args.event == "BufAdd" or vim.bo[args.buf].buflisted) then
table.insert(bufs, args.buf) table.insert(bufs, args.buf)
vim.t.bufs = bufs vim.t.bufs = bufs
end end