-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Conversation
pablobfonseca
commented
May 20, 2024
- support nvim < 0.10
- support nvim < 0.10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for the PR, I've made a comment to hopefully reduce the potential cost of the logic but otherwise looks good to me
lua/bufferline/utils/init.lua
Outdated
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks LGTM
* 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()