From 74049a11517ffb608bf64aabcc96535d1bc7b298 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 22 Jul 2016 09:50:20 -0400 Subject: Fixed infinite loop with "Replace All" in selection; modules/textadept/find.lua This happens when the replacement text matches the find text and is longer in length. --- modules/textadept/find.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 9652f474..24c4ecc8 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -148,7 +148,7 @@ local function find(text, next, flags, no_wrap, wrapped) -- If text is selected, assume it is from the current search and increment the -- caret appropriately for the next search. if not buffer.selection_empty then - local pos = buffer[next and 'current_pos' or 'anchor'] + local pos = buffer[next and 'selection_end' or 'selection_start'] buffer:goto_pos(buffer:position_relative(pos, next and 1 or -1)) end @@ -312,6 +312,7 @@ local function replace(rtext) if M.in_files then M.in_files = false end buffer:target_from_selection() buffer[not M.regex and 'replace_target' or 'replace_target_re'](buffer, rtext) + buffer:set_sel(buffer.target_start, buffer.target_end) end events.connect(events.REPLACE, replace) -- cgit v1.2.3