From 1e278dce5dab93b73a3699aa2cc54fa6db11f34f Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 13 Jul 2020 14:30:36 -0400 Subject: 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. --- modules/textadept/find.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/textadept/find.lua') 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) -- cgit v1.2.3