Replace globally when replacing from selection (#1331)
This commit is contained in:
parent
3f917dcb45
commit
aef400bc90
|
@ -211,6 +211,7 @@ command.add("core.docview!", {
|
||||||
["find-replace:replace"] = function()
|
["find-replace:replace"] = function()
|
||||||
local l1, c1, l2, c2 = doc():get_selection()
|
local l1, c1, l2, c2 = doc():get_selection()
|
||||||
local selected_text = doc():get_text(l1, c1, l2, c2)
|
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)
|
replace("Text", l1 == l2 and selected_text or "", function(text, old, new)
|
||||||
if not find_regex then
|
if not find_regex then
|
||||||
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
|
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
|
||||||
|
|
Loading…
Reference in New Issue