summaryrefslogtreecommitdiffstats
path: root/pairs.lua
diff options
context:
space:
mode:
authorGeorgi Kirilov <>2020-11-22 15:10:50 +0200
committerGeorgi Kirilov <>2023-10-04 18:24:59 +0800
commitf98cd75d5d6e3d5f7fd7f414ecf197d32598851f (patch)
treed673d650ffb57fa095d81d915e3a45faeed78332 /pairs.lua
parent7a12d5adef1328c43e2c6ed36ee8cc3fb1b57764 (diff)
downloadvis-pairs-f98cd75d5d6e3d5f7fd7f414ecf197d32598851f.tar.gz
Keep context for asymmetric delimiters, too
Complements 3a61bc03, where only the symmetric ones were fixed.
Diffstat (limited to 'pairs.lua')
-rw-r--r--pairs.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/pairs.lua b/pairs.lua
index 2380c47..60ea374 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -42,13 +42,14 @@ local function at_pos(t, pos)
if pos >= t[1] and pos < t[#t] then return t end
end
-local function asymmetric(d, pos)
+local function asymmetric(d, escaped, pos)
local p
local I = l.Cp()
+ local skip = escaped and escaped + l.P(1) or l.P(1)
if #d == 1 then
- p = (d - l.B"\\") * I * ("\\" * l.P(1) + (l.P(1) - d))^0 * I * d
+ p = (d - l.B"\\") * I * ("\\" * l.P(1) + (skip - d))^0 * I * d
else
- p = d * I * (l.P(1) - d)^0 * I * d
+ p = d * I * (skip - d)^0 * I * d
end
return l.Ct(I * p * I) * l.Cc(pos) / at_pos
end
@@ -156,7 +157,7 @@ local function get_range(key, win, pos, file_data)
pos = pos - (range[1] - 1)
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 p = d[1] ~= d[2] and symmetric(d[1], d[2], c.escape, pos + 1) or asymmetric(d[1], c.escape, 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