Replace globally when replacing from selection (#1331)

This commit is contained in:
Himura Kazuto 2023-01-31 01:00:48 +08:00 committed by George Sokianos
parent 06cb09cb93
commit 623419adfa
1 changed files with 1 additions and 0 deletions

View File

@ -211,6 +211,7 @@ command.add("core.docview!", {
["find-replace:replace"] = function()
local l1, c1, l2, c2 = doc():get_selection()
local selected_text = doc():get_text(l1, c1, l2, c2)
doc():set_selection(l2, c2, l2, c2)
replace("Text", l1 == l2 and selected_text or "", function(text, old, new)
if not find_regex then
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)