diff options
author | 2016-07-22 09:50:20 -0400 | |
---|---|---|
committer | 2016-07-22 09:50:20 -0400 | |
commit | 74049a11517ffb608bf64aabcc96535d1bc7b298 (patch) | |
tree | 93fc47f139beb520c25e015bc4c12eb85efdeb89 /modules | |
parent | a035724adfe0a10f42b89ae60c89e42c23427125 (diff) | |
download | textadept-74049a11517ffb608bf64aabcc96535d1bc7b298.tar.gz textadept-74049a11517ffb608bf64aabcc96535d1bc7b298.zip |
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.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/textadept/find.lua | 3 |
1 files changed, 2 insertions, 1 deletions
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) |