Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace tbl_flatten to flatten():totable() #912

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
4 changes: 4 additions & 0 deletions lua/bufferline/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,8 @@ else
M.is_list = vim.tbl_isarray or vim.tbl_islist
end

function M.tbl_flatten(t)
return vim.fn.has("nvim-0.10") == 1 and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pull this check out to the files top level as it's a static value really to prevent having to recalculate this every time this function is called

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akinsho done! let me know if that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akinsho I changed to check for the version 0.11 for flatten like it's being done on the telescope plugin:
https://github.com/nvim-telescope/telescope.nvim/blob/4aed63995a69e343b068c7469491a8d1592c339f/plugin/telescope.lua#L121

end

return M