summaryrefslogtreecommitdiffstats
path: root/pairs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'pairs.lua')
-rw-r--r--pairs.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/pairs.lua b/pairs.lua
index 5894105..49ec19a 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -61,16 +61,14 @@ local function symmetric(d1, d2, escaped, pos)
end
local function nth_innermost(t, count)
- if type(t) == "table" then
- local start, finish, c = 0, 0, count
- if #t == 5 then
- start, finish, c = nth_innermost(t[3], count)
- end
- if c then
- return {t[1], t[2]}, {t[#t - 1], t[#t]}, c > 1 and c - 1 or nil
- end
- return start, finish
+ local start, finish, c = 0, 0, count
+ if #t == 5 then
+ start, finish, c = nth_innermost(t[3], count)
+ end
+ if c then
+ return {t[1], t[2]}, {t[#t - 1], t[#t]}, c > 1 and c - 1 or nil
end
+ return start, finish
end
local precedence = {
@@ -162,8 +160,10 @@ local function get_range(key, win, pos, file_data, count)
local data = c.range and file_data:sub(unpack(c.range)) or file_data
local pattern = l.P{l.Cmt(p * l.Cc(can_abut and 1 or 0), any_captures) + skip * l.Cmt(l.Cc(pos + 1), not_past) * l.V(1)}
prev_match = 0
- offsets = {nth_innermost(pattern:match(data), count or 1)}
- offsets[3] = nil
+ local hierarchy = pattern:match(data)
+ if not hierarchy then return end
+ offsets = {nth_innermost(hierarchy, count or 1)}
+ offsets[3] = nil -- a leftover from calling nth_innermost() with count higher than the hierarchy depth.
if #offsets == 0 then
pos = correction - 1
end