From aef400bc90e38088a1bdd01671784bd275559dc7 Mon Sep 17 00:00:00 2001 From: Himura Kazuto Date: Tue, 31 Jan 2023 01:00:48 +0800 Subject: [PATCH] Replace globally when replacing from selection (#1331) --- data/core/commands/findreplace.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/data/core/commands/findreplace.lua b/data/core/commands/findreplace.lua index 4a456aae..0125a0a1 100644 --- a/data/core/commands/findreplace.lua +++ b/data/core/commands/findreplace.lua @@ -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)