aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/find.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-07-13 14:30:36 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-07-13 14:30:36 -0400
commit1e278dce5dab93b73a3699aa2cc54fa6db11f34f (patch)
treec3b58e90f15b2443e74d1cceb0749a94bb7a5d3c /modules/textadept/find.lua
parentde57ae800e07e36e21741ff8983f64ed24ff16f9 (diff)
downloadtextadept-1e278dce5dab93b73a3699aa2cc54fa6db11f34f.tar.gz
textadept-1e278dce5dab93b73a3699aa2cc54fa6db11f34f.zip
Auto-highlight all occurrences of selected words and find results.
This supercedes `textadept.editing.highlight_word()`, which has been removed. Changed the color of word highlights in themes.
Diffstat (limited to 'modules/textadept/find.lua')
-rw-r--r--modules/textadept/find.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index c34ce370..22a6a376 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -124,6 +124,19 @@ local function find(text, next, flags, no_wrap, wrapped)
if flags >= 1 << 31 then M.find_in_files() return end -- not performed here
local first_visible_line = view.first_visible_line -- for 'no results found'
+ -- Highlight all occurrences first, otherwise regex tags will be overwritten.
+ buffer.indicator_current = ui.INDIC_HIGHLIGHT
+ buffer:indicator_clear_range(1, buffer.length)
+ if ui.highlight_words and #text > 1 then
+ buffer.search_flags = flags
+ buffer:target_whole_document()
+ while buffer:search_in_target(text) ~= -1 do
+ buffer:indicator_fill_range(
+ buffer.target_start, buffer.target_end - buffer.target_start)
+ buffer:set_target_range(buffer.target_end, buffer.length + 1)
+ end
+ end
+
-- If text is selected, assume it is from the current search and move the
-- caret appropriately for the next search.
buffer:goto_pos(next and buffer.selection_end or buffer.selection_start)