summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/require/result_view.lua
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-03 12:34:21 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-03 12:34:21 -0400
commit6a4b9b1184c142ca1b317296fa12304bf231fc7d (patch)
treefb0ec390ed6633180e2635afd425a17ed0c2ebd1 /indra/newview/scripts/lua/require/result_view.lua
parent9dc916bfcafd43890be20623d359be82e84f73ac (diff)
Add test_result_view.lua; fix minor bugs in result_view.lua.
Diffstat (limited to 'indra/newview/scripts/lua/require/result_view.lua')
-rw-r--r--indra/newview/scripts/lua/require/result_view.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/indra/newview/scripts/lua/require/result_view.lua b/indra/newview/scripts/lua/require/result_view.lua
index 4a58636f2f..d53d953c24 100644
--- a/indra/newview/scripts/lua/require/result_view.lua
+++ b/indra/newview/scripts/lua/require/result_view.lua
@@ -23,7 +23,8 @@ local function result_view(key_length, fetch)
-- can we find this index within the current slice?
local reli = i - this.start
if 0 <= reli and reli < #this.slice then
- return this.slice[reli]
+ -- Lua 1-relative indexing
+ return this.slice[reli + 1]
end
-- is this index outside the overall result set?
if not (0 <= i and i < this.length) then
@@ -31,16 +32,17 @@ local function result_view(key_length, fetch)
end
-- fetch a new slice starting at i, using provided fetch()
local start
- this.slice, start = fetch(key, i)
+ this.slice, start = fetch(this.key, i)
-- It's possible that caller-provided fetch() function forgot
-- to return the adjusted start index of the new slice. In
-- Lua, 0 tests as true, so if fetch() returned (slice, 0),
- -- we'll duly reset this.start to 0.
- if start then
- this.start = start
- end
- -- hopefully this slice contains the desired i
- return this.slice[i - this.start]
+ -- we'll duly reset this.start to 0. Otherwise, assume the
+ -- requested index was not adjusted: that the returned slice
+ -- really does start at i.
+ this.start = start or i
+ -- Hopefully this slice contains the desired i.
+ -- Back to 1-relative indexing.
+ return this.slice[i - this.start + 1]
end,
-- We purposely avoid putting any array entries (int keys) into
-- our table so that access to any int key will always call our