Skip to content

Commit

Permalink
fix: replace tbl_flatten to flatten():totable() (#912)
Browse files Browse the repository at this point in the history
* fix: replace tbl_flatten to flatten():totable()

- support nvim < 0.10

* fix: extract nvim version check to a variable

* fix: check if is nvim 0.11 for flatten()
  • Loading branch information
pablobfonseca committed May 21, 2024
1 parent 0dfc19b commit b2dc003
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/bufferline/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ local function to_tabline_str(component)
table.insert(str, 1, attr[1])
table.insert(str, #str + 1, attr[1])
end
return table.concat(vim.tbl_flatten(str))
return table.concat(utils.tbl_flatten(str))
end

--- PREREQUISITE: active buffer always remains in view
Expand Down
6 changes: 6 additions & 0 deletions lua/bufferline/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ local M = {}
local fn, api = vim.fn, vim.api
local strwidth = api.nvim_strwidth

local isNvimEleven = vim.fn.has("nvim-0.11") == 1

function M.is_test()
---@diagnostic disable-next-line: undefined-global
return __TEST
Expand Down Expand Up @@ -275,4 +277,8 @@ else
M.is_list = vim.tbl_isarray or vim.tbl_islist
end

function M.tbl_flatten(t)
return isNvimEleven and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t)
end

return M

0 comments on commit b2dc003

Please sign in to comment.