Replace globally when replacing from selection (#1331)

This commit is contained in:
Himura Kazuto 2023-01-31 01:00:48 +08:00 committed by GitHub
parent 719540e73d
commit 0a0754d1c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)