From bebf8d4fca9cc636e438f2864b369402fc13dbc1 Mon Sep 17 00:00:00 2001 From: rxi Date: Mon, 3 Mar 2014 18:56:12 +0000 Subject: [PATCH] Fixed bug with negative j index in lume.slice() Fixed a bug where giving lume.slice() a negative j index (or no j index) would not result in the correct slice -- the behaviour now correctly matches that of string.sub() when passing a negative j index. --- lume.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lume.lua b/lume.lua index f3cb91d..6c40fef 100644 --- a/lume.lua +++ b/lume.lua @@ -157,7 +157,7 @@ end function lume.slice(t, i, j) i = i or 1 - j = j and (j < 0 and (#t + j) or j) or (#t - i + 1) + j = j and (j < 0 and (#t + j + 1) or j) or #t local rtn = {} for i = math.max(i, 1), math.min(j, #t) do rtn[#rtn + 1] = t[i]