Fixed regex replace.

This commit is contained in:
Adam Harrison 2021-06-20 22:24:20 -04:00
parent 46e939a3e6
commit 8b2fb67b9b
1 changed files with 3 additions and 2 deletions

View File

@ -112,11 +112,12 @@ command.add("core.docview", {
end,
["find-replace:replace"] = function()
replace("Text", function(text, old, new)
replace("Text", doc():get_text(doc():get_selection(true)), function(text, old, new)
if plain then
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
end
return regex.gsub(regex.compile(old), text, new)
local result, matches = regex.gsub(regex.compile(old), text, new)
return result, #matches
end)
end,