Skip to content

Commit

Permalink
fix(groups): only reset the pinned group if it closed (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
otavioschwanck committed Feb 23, 2023
1 parent 894d0e8 commit 2c232bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lua/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function M.group_action(name, action)
if action == "close" then
groups.command(name, function(b) api.nvim_buf_delete(b.id, { force = true }) end)
ui.refresh()
groups.reset_manual_groupings()

groups.reset_manual_groupings(name)
elseif action == "toggle" then
groups.toggle_hidden(nil, name)
ui.refresh()
Expand Down
14 changes: 11 additions & 3 deletions lua/bufferline/groups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,17 @@ local function sort_by_groups(components)
end

--- Resets manual mappings.
function M.reset_manual_groupings()
vim.g[PINNED_KEY] = {}
state.manual_groupings = {}
---@param name string Group name
function M.reset_manual_groupings(name)
if name == PINNED_NAME then
vim.g[PINNED_KEY] = {}
end

for buf, group_id in pairs(state.manual_groupings) do
if group_id == name then
state.manual_groupings[buf] = nil
end
end
end

function M.get_all() return state.user_groups end
Expand Down

0 comments on commit 2c232bf

Please sign in to comment.