From ca6dbf3558cec83f1d42a1e5f670c40c5893554e Mon Sep 17 00:00:00 2001 From: Calvin Bochulak Date: Sat, 23 Mar 2024 15:46:54 -0600 Subject: fix(vim.iter): use correct cmp function when truncating tail in `take` (#27998) --- runtime/lua/vim/iter.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/iter.lua b/runtime/lua/vim/iter.lua index a37b7f7858..2f2c21aee8 100644 --- a/runtime/lua/vim/iter.lua +++ b/runtime/lua/vim/iter.lua @@ -709,7 +709,8 @@ end ---@private function ListIter:take(n) local inc = self._head < self._tail and 1 or -1 - self._tail = math.min(self._tail, self._head + n * inc) + local cmp = self._head < self._tail and math.min or math.max + self._tail = cmp(self._tail, self._head + n * inc) return self end -- cgit