diff options
author | 2020-08-20 23:17:19 -0400 | |
---|---|---|
committer | 2020-08-20 23:17:19 -0400 | |
commit | 1b35a0de0f05d2db27fa3af211e3098c8a20caec (patch) | |
tree | 85a8583919810ae4ecb7d3f497fb0a805083c9d0 /modules/textadept | |
parent | 30f5250828d0dffe9bf14cf48db530ddf6ca3c9d (diff) | |
download | textadept-1b35a0de0f05d2db27fa3af211e3098c8a20caec.tar.gz textadept-1b35a0de0f05d2db27fa3af211e3098c8a20caec.zip |
Show "Match X/Y" in statusbar when searching for text.
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/find.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 761b70d0..ffc4d2b2 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -220,17 +220,23 @@ local function find(text, next, flags, no_wrap, wrapped) ui.statusbar_text = '' end - -- Highlight all found occurrences. + -- Count and optionally highlight all found occurrences. + local count, current = 0 clear_highlighted_matches() - if pos ~= -1 and M.highlight_all_matches and #text > 1 then + if pos ~= -1 then buffer.search_flags = flags buffer:target_whole_document() while buffer:search_in_target(text) ~= -1 do local s, e = buffer.target_start, buffer.target_end if s == e then break end -- prevent loops - buffer:indicator_fill_range(s, e - s) + if M.highlight_all_matches and e - s > 1 then + buffer:indicator_fill_range(s, e - s) + end buffer:set_target_range(e, buffer.length + 1) + count = count + 1 + if s == pos then current = count end end + ui.statusbar_text = string.format('%s %d/%d', _L['Match'], current, count) -- For regex searches, `buffer.tag` was clobbered. It needs to be filled in -- again for any subsequent replace operations that need it. if ui.find.regex then |