diff options
Diffstat (limited to 'pairs.lua')
-rw-r--r-- | pairs.lua | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -91,7 +91,9 @@ local function any_captures(_, position, t) if type(t) == "table" then return position, t end - prev_match = position + if t then + prev_match = position - t + end end local function not_past(_, position, pos) @@ -103,7 +105,7 @@ local function match_at(str, pattern, pos) local string_pos = pos + 1 prev_match = 0 local I = l.Cp() - local p = l.P{l.Cmt(l.Ct(I * (pattern/0) * I) * l.Cc(string_pos) / at_pos, any_captures) + 1 * l.Cmt(l.Cc(string_pos), not_past) * l.V(1)} + local p = l.P{l.Cmt(l.Ct(I * (pattern/0) * I) * l.Cc(string_pos) / at_pos * l.Cc(0), any_captures) + 1 * l.Cmt(l.Cc(string_pos), not_past) * l.V(1)} local t = p:match(str) if not t then return end return t[1] - 1, t[#t] - 1 @@ -155,9 +157,10 @@ local function get_range(key, win, pos, file_data) end correction = range[1] - 1 local p = d[1] ~= d[2] and symmetric(d[1], d[2], c.escape, pos + 1) or asymmetric(d[1], pos + 1) + local can_abut = d[1] == d[2] and #d[1] == 1 and not (builtin_textobjects[key] or M.map[1][key] or M.map[win.syntax] and M.map[win.syntax][key]) local skip = c.escape and c.escape + 1 or 1 local data = c.range and file_data:sub(unpack(c.range)) or file_data - local pattern = l.P{l.Cmt(p, any_captures) + skip * l.Cmt(l.Cc(pos + 1), not_past) * l.V(1)} + 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(pattern:match(data))} offsets[3] = nil |