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

Conversation

pablobfonseca
Copy link
Contributor

  • support nvim < 0.10

Copy link
Owner

@akinsho akinsho left a 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

@@ -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

Copy link
Owner

@akinsho akinsho left a comment

Choose a reason for hiding this comment

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

Thanks LGTM

@akinsho akinsho merged commit b2dc003 into akinsho:main May 21, 2024
1 check passed
sstallion pushed a commit to sstallion/bufferline.nvim that referenced this pull request Jul 3, 2024
* 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants