A-B: escape magic characters in the indicator
This commit is contained in:
parent
e8e7dc9909
commit
ff4d6f2902
|
@ -33,6 +33,11 @@ local function get_indicator(letter, actor)
|
||||||
return indicator
|
return indicator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function escape_pattern(txt)
|
||||||
|
local magic_chars = "%^%$%(%)%%.%[%]%*%+%-%?"
|
||||||
|
return txt:gsub("(["..magic_chars.."])", "%%%1")
|
||||||
|
end
|
||||||
|
|
||||||
local function main(sub, sel)
|
local function main(sub, sel)
|
||||||
local i = "a"
|
local i = "a"
|
||||||
for _,li in ipairs(sel) do
|
for _,li in ipairs(sel) do
|
||||||
|
@ -60,7 +65,8 @@ local function undo(sub, sel)
|
||||||
if line.text == indicator then
|
if line.text == indicator then
|
||||||
line.text = ""
|
line.text = ""
|
||||||
else
|
else
|
||||||
line.text = line.text:gsub(indicator.."$", "")
|
local escaped = escape_pattern(indicator)
|
||||||
|
line.text = line.text:gsub(escaped, "")
|
||||||
end
|
end
|
||||||
sub[li] = line
|
sub[li] = line
|
||||||
i = switch_indicator(i)
|
i = switch_indicator(i)
|
||||||
|
|
Loading…
Reference in New Issue