Skip to content

Commit

Permalink
fix(state): resolve conflict with neo-tree.nvim
Browse files Browse the repository at this point in the history
- Only restore the last winbar when the winbar was affected by barbecue
  previously.
- Do not remove the last winbar from window variables.

Related: #54, #53
  • Loading branch information
utilyre committed Jan 27, 2023
1 parent 55fc11e commit cbc4481
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lua/barbecue/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ function M.update(winnr)
or vim.tbl_contains(config.user.exclude_filetypes, vim.bo[bufnr].filetype)
or vim.api.nvim_win_get_config(winnr).relative ~= ""
then
vim.wo[winnr].winbar = state.get_last_winbar(winnr)
local last_winbar = state.get_last_winbar(winnr)
if last_winbar ~= nil then vim.wo[winnr].winbar = last_winbar end

state.clear(winnr)

return
Expand Down
9 changes: 6 additions & 3 deletions lua/barbecue/ui/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ local VAR_ENTRIES = "barbecue_entries"
---@param winnr number
---@return string|nil
function M.get_last_winbar(winnr)
local was_affected_ok, was_affected =
pcall(vim.api.nvim_win_get_var, winnr, VAR_WAS_AFFECTED)
if not was_affected_ok or not was_affected then return nil end

local last_winbar_ok, last_winbar =
pcall(vim.api.nvim_win_get_var, winnr, VAR_LAST_WINBAR)

Expand Down Expand Up @@ -42,9 +46,8 @@ end
function M.save(winnr, entries)
local was_affected_ok, was_affected =
pcall(vim.api.nvim_win_get_var, winnr, VAR_WAS_AFFECTED)
if was_affected_ok and was_affected then
pcall(vim.api.nvim_win_del_var, winnr, VAR_LAST_WINBAR)
else

if not was_affected_ok or not was_affected then
vim.api.nvim_win_set_var(winnr, VAR_WAS_AFFECTED, true)
vim.api.nvim_win_set_var(winnr, VAR_LAST_WINBAR, vim.wo[winnr].winbar)
end
Expand Down

0 comments on commit cbc4481

Please sign in to comment.