summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/lua/iter_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-02-12feat(iter): peek(), skip(predicate) for non-list iterators #37604Elijah Koulaxis1
Problem: Iter:peek() only works if the iterator is a |list-iterator| (internally, an `ArrayIter`). However, it is possible to implement :peek() support for any iterator. Solution: - add `_peeked` buffer for lookahead without actually consuming values - `peek()` now works for function, pairs(), and array iterators - `skip(predicate)` stops at the first non matching element without consuming it - keep existing optimized behavior for `ArrayIter` to maintain backward compatibility - use `pack`/`unpack` to support iterators that return multiple values
2026-02-10feat(lua): add `Iter:unique()` (#37592)Olivia Kinnear1
2025-07-22fix(iter): ArrayIter:last returns nil when filtered to empty #34697glepnir1
Problem: After filtering out all elements, ArrayIter:last still returns a stale element. Solution: Add check for self._head == self._tail and return nil early. Fix #34696
2025-07-03feat(runtime): accept predicates in take and skip (#34657)Mart-Mihkel Aun1
Make `vim.iter():take()` and `vim.iter():skip()` optionally accept predicates to enable takewhile and skipwhile patterns used in functional programming.
2024-05-17fix(vim.iter): enable optimizations for arrays (lists with holes) (#28781)Gregory Anders1
The optimizations that vim.iter uses for array-like tables don't require that the source table has no holes. The only thing that needs to change is the determination if a table is "list-like": rather than requiring consecutive, integer keys, we can simply test for (positive) integer keys only, and remove any holes in the original array when we make a copy for the iterator.
2024-04-26refactor(vim.iter)!: rename xxback() => rxx() #28503Justin M. Keyes1
Problem: vim.iter has both `rfind()` and various `*back()` methods, which work in "reverse" or "backwards" order. It's inconsistent to have both kinds of names, and "back" is fairly uncommon (rust) compared to python (rfind, rstrip, rsplit, …). Solution: - Remove `nthback()` and let `nth()` take a negative index. - Because `rnth()` looks pretty obscure, and because it's intuitive for a function named `nth()` to take negative indexes. - Rename `xxback()` methods to `rxx()`. - This informally groups the "list-iterator" functions under a common `r` prefix, which helps discoverability. - Rename `peekback()` to `pop()`, in duality with the existing `peek`.
2024-04-23test: improve test conventionsdundargoc1
Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
2024-04-10refactor(test): inject after_each differentlyLewis Russell1
2024-04-08test: improve test conventionsdundargoc1
Work on https://github.com/neovim/neovim/issues/27004.
2024-03-23fix(vim.iter): use correct cmp function when truncating tail in `take` (#27998)Calvin Bochulak1
2024-01-10feat(vim.iter): add Iter:flatten (#26786)JD1
Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jongwook Choi <wookayin@gmail.com>
2024-01-03refactor: format test/*Justin M. Keyes1
2023-12-12feat(iter): add `Iter.take` (#26525)Will Hopkins1
2023-12-05feat(lua): implement Iter:join() (#26416)Gregory Anders1
2023-08-09fix(iter): make pipeline termination conditions consistent (#24614)Gregory Anders1
If an iterator pipeline stage returns nil as its first return value, the other return values are ignored and it is treated as if that stage returned only nil (the semantics of returning nil are different between different stages). This is consistent with how for loops work in Lua more generally, where the for loop breaks when the first return value from the function iterator is nil (see :h for-in for details).
2023-06-10feat(lua): use callable table as iterator in vim.iter (#23957)Mathias Fußenegger1
A table passed to `vim.iter` can be a class instance with a `__call` implementation for the iterator protocol.
2023-04-24test: move vim.iter tests to separate fileGregory Anders1