Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Fix the allowed_buffers table #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lua/tabline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ end
function M._bind_buffers(args)
local filelist = {}
if #args == 0 then
filelist[#filelist + 1] = vim.fn.expand("%:p:~")
filelist[vim.fn.expand("%:p:~")] = true
else
for _, buffer_name in pairs(args) do
filelist[#filelist + 1] = vim.fn.fnamemodify(vim.fn.expand(buffer_name), ":p:~")
filelist[vim.fn.fnamemodify(vim.fn.expand(buffer_name), ":p:~")] = true
end
end
local data = vim.fn.json_decode(vim.g.tabline_tab_data)
Expand Down Expand Up @@ -570,15 +570,6 @@ function M.fzf_bind_buffers()
end)()
end

local function contains(list, x)
for i, v in pairs(list) do
if v == x then
return true
end
end
return false
end

function M.tabline_buffers(opt)
opt = M.options

Expand All @@ -597,7 +588,7 @@ function M.tabline_buffers(opt)
buffers[#buffers + 1] = buffer
else
local filepath = vim.fn.expand("#" .. buffer.bufnr .. ":p:~")
if current_tab and contains(current_tab.allowed_buffers, filepath) then
if current_tab and current_tab.allowed_buffers[filepath] then
buffers[#buffers + 1] = buffer
end
end
Expand Down