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

vim.iter: flatten() non-list input #28448

Open
justinmk opened this issue Apr 21, 2024 · 0 comments
Open

vim.iter: flatten() non-list input #28448

justinmk opened this issue Apr 21, 2024 · 0 comments
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request lua stdlib needs:discussion For PRs that propose significant changes to some part of the architecture or API
Milestone

Comments

@justinmk
Copy link
Member

justinmk commented Apr 21, 2024

Problem

iter:flatten() currently fails ("flatten() requires a list-like table") on this code from gen_lsp.lua:

neovim/scripts/gen_lsp.lua

Lines 262 to 265 in 35e3883

local anonym = vim.tbl_flatten { -- remove nil
anonymous_num > 1 and '' or nil,
'---@class ' .. anonymous_classname,
}

local anonym = vim.iter({ -- remove nil
  anonymous_num > 1 and '' or nil,
  '---@class ' .. anonymous_classname,
}):flatten():totable()

Expected behavior

tbl_flatten accepted array-like input and the above gen_lsp code leveraged that to drop nil items.

Can we enhance Iter:flatten() to work for arrays?

@justinmk justinmk added enhancement feature request lua stdlib complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md labels Apr 21, 2024
@justinmk justinmk added this to the backlog milestone Apr 21, 2024
@justinmk justinmk added the needs:discussion For PRs that propose significant changes to some part of the architecture or API label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request lua stdlib needs:discussion For PRs that propose significant changes to some part of the architecture or API
Projects
None yet
Development

No branches or pull requests

1 participant