aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-05 16:51:17 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-05 16:51:17 -0400
commit9952db760ae205d25de900349ac0fc6ae33b7be9 (patch)
tree800392a9086c411501f1026f96c40d8b607c530b /modules
parentd88a65ae78190eb6a2a94938c93c87c2148c60fc (diff)
Fixed advancing caret for incremental find when text is not found.
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/find.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 59d2c002..b8d37eed 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -166,6 +166,7 @@ events.connect(events.KEYPRESS, function(code)
clear_highlighted_matches()
end, 1)
+local incremental_orig_pos
-- Finds and selects text in the current buffer.
-- @param text The text to find.
-- @param next Flag indicating whether or not the search direction is forward.
@@ -186,15 +187,17 @@ local function find(text, next, flags, no_wrap, wrapped)
local first_visible_line = view.first_visible_line -- for 'no results found'
if M.incremental and not wrapped then
+ local pos = buffer.current_pos
if type(M.incremental) == 'boolean' then
-- Starting a new incremental search, anchor at current pos.
- M.incremental = buffer.current_pos
+ M.incremental, incremental_orig_pos = pos, pos
elseif text == find_text then
-- "Find Next" or "Find Prev" clicked, anchor at new current pos.
- M.incremental = buffer:position_relative(
- buffer.current_pos, next and 1 or -1)
+ M.incremental = buffer:position_relative(pos, next and 1 or -1)
end
buffer:goto_pos(M.incremental or 1)
+ elseif not M.incremental then
+ incremental_orig_pos = nil
end
-- If text is selected, assume it is from the current search and move the
@@ -221,7 +224,7 @@ local function find(text, next, flags, no_wrap, wrapped)
if pos == -1 then
ui.statusbar_text = _L['No results found']
view:line_scroll(0, first_visible_line - view.first_visible_line)
- buffer:goto_pos(anchor)
+ buffer:goto_pos(incremental_orig_pos or anchor)
end
elseif not wrapped then
ui.statusbar_text = ''