From 8b2fb67b9b5a2b4e7d4563b0e2ae11b6cc3751bb Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 20 Jun 2021 22:24:20 -0400 Subject: [PATCH] Fixed regex replace. --- data/core/commands/findreplace.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/core/commands/findreplace.lua b/data/core/commands/findreplace.lua index aadae66..e5d7c70 100644 --- a/data/core/commands/findreplace.lua +++ b/data/core/commands/findreplace.lua @@ -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,