aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
authormitchell <70453897+orbitalquark@users.noreply.github.com>2020-09-07 10:28:58 -0400
committermitchell <70453897+orbitalquark@users.noreply.github.com>2020-09-07 10:28:58 -0400
commit13d97f714e2f52fef6a49757d3db3bb1c5a358e5 (patch)
tree2f7a5511eb62464566fec575a01f30d63d26653e /modules/textadept
parent7a98e09ae4b424031835cdb8986d93926c7ac0bd (diff)
downloadtextadept-13d97f714e2f52fef6a49757d3db3bb1c5a358e5.tar.gz
textadept-13d97f714e2f52fef6a49757d3db3bb1c5a358e5.zip
Added `events.FIND_RESULT_FOUND` and reverted scrolling change.
Users who want to vertically center the caret or similar can connect to the event.
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/find.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index c5c3118d..520b977e 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -63,6 +63,9 @@ local M = ui.find
-- The default value is `false`.
-- @field INDIC_FIND (number)
-- The find results highlight indicator number.
+-- @field _G.events.FIND_RESULT_FOUND (string)
+-- Emitted when a result is found. It is selected and has been scrolled into
+-- view.
-- @field _G.events.FIND_WRAPPED (string)
-- Emitted when a text search wraps (passes through the beginning of the
-- buffer), either from bottom to top (when searching for a next occurrence),
@@ -87,7 +90,7 @@ M.highlight_all_matches = false
M.INDIC_FIND = _SCINTILLA.next_indic_number()
-- Events.
-events.FIND_WRAPPED = 'find_wrapped'
+events.FIND_RESULT_FOUND, events.FIND_WRAPPED = 'find_found', 'find_wrapped'
-- When finding in files, note the current view since results are shown in a
-- split view. Jumping between results should be done in the original view.
@@ -202,7 +205,7 @@ local function find(text, next, flags, no_wrap, wrapped)
local pos = f(buffer, flags, text)
view:ensure_visible_enforce_policy(buffer:line_from_position(pos))
view:scroll_range(buffer.anchor, buffer.current_pos)
- view:vertical_center_caret()
+ events.emit(events.FIND_RESULT_FOUND)
-- Track find text and found text for "replace all" and incremental find.
find_text, found_text = text, buffer:get_sel_text()
repl_text = ui.find.replace_entry_text -- save for ui.find.focus()