fix(vim.iter): use correct cmp function when truncating tail in take (#27998)

This commit is contained in:
Calvin Bochulak
2024-03-23 15:46:54 -06:00
committed by GitHub
parent 3d9c028a4c
commit ca6dbf3558
2 changed files with 8 additions and 1 deletions

View File

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