diff options
author | Georgi Kirilov <> | 2020-11-22 15:10:50 +0200 |
---|---|---|
committer | Georgi Kirilov <> | 2023-10-04 18:24:59 +0800 |
commit | 83fbeb65b818d1f23ba4c6422965b8c372b54247 (patch) | |
tree | ba7ec2c199d39dc4f01c80233a465ba6a9f50ad8 | |
parent | d43d7b5288fddbcd52a02f890e25f542916b2f0f (diff) | |
download | vis-pairs-83fbeb65b818d1f23ba4c6422965b8c372b54247.tar.gz |
Fix a crash
-rw-r--r-- | pairs.lua | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -139,12 +139,11 @@ end local function get_range(key, win, pos, file_data, count) local d = get_pair(key, win) if not d then return end - local offsets, correction repeat local sel_range = selection_range(win, pos) local c = escaping_context(win, sel_range, file_data) local range = c.range or {1, #file_data} - correction = range[1] - 1 + local correction = range[1] - 1 pos = pos - correction if sel_range then sel_range.start = sel_range.start - correction @@ -160,18 +159,18 @@ local function get_range(key, win, pos, file_data, count) prev_match = 0 local hierarchy = pattern:match(data) if hierarchy then - offsets = {nth_innermost(hierarchy, count or 1)} + local offsets = {nth_innermost(hierarchy, count or 1)} offsets[3] = nil -- a leftover from calling nth_innermost() with count higher than the hierarchy depth. + for _, o in ipairs(offsets) do + for i, v in ipairs(o) do + o[i] = v - 1 + correction + end + end + return unpack(offsets) else pos = correction - 1 end until hierarchy or pos < 0 - for _, o in ipairs(offsets) do - for i, v in ipairs(o) do - o[i] = v - 1 + correction - end - end - return unpack(offsets) end local function keep_last(acc, cur) |