From 937573720058266869cdddf0d6f881ee4f706381 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:32:49 -0500 Subject: Added `ui.find.show_filenames_in_progressbar` option. Showing filenames can actually slow down searches on computers with really fast SSDs. Informal tests with a PCIe 3.0 x4 SSD show a ~25% speedup when not showing filenames. --- modules/textadept/find.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index b570c30a..d206c2dc 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -63,6 +63,11 @@ local M = ui.find -- @field highlight_all_matches (boolean) -- Whether or not to highlight all occurrences of found text in the current buffer. -- The default value is `false`. +-- @field show_filenames_in_progressbar (boolean) +-- Whether to show filenames in the find in files search progressbar. +-- This can be useful for determining whether or not custom filters are working as expected. +-- Showing filenames can slow down searches on computers with really fast SSDs. +-- The default value is `true`. -- @field INDIC_FIND (number) -- The find results highlight indicator number. -- @field _G.events.FIND_RESULT_FOUND (string) @@ -89,6 +94,7 @@ M.whole_word_label_text = not CURSES and _L['Whole word'] or _L['Word(F2)'] M.regex_label_text = not CURSES and _L['Regex'] or _L['Regex(F3)'] M.in_files_label_text = not CURSES and _L['In files'] or _L['Files(F4)'] M.highlight_all_matches = false +M.show_filenames_in_progressbar = true M.INDIC_FIND = _SCINTILLA.next_indic_number() @@ -320,10 +326,11 @@ function M.find_in_files(dir, filter) view:goto_buffer(orig_buffer) buffer.code_page = 0 -- default is UTF-8 buffer.search_flags = get_flags() - local text, i, found = M.find_entry_text, 1, false + local text, i, found, show_names = M.find_entry_text, 1, false, M.show_filenames_in_progressbar local stopped = ui.dialogs.progressbar({ title = string.format('%s: %s', _L['Find in Files']:gsub('_', ''), text), - text = utf8_filenames[i], stoppable = true + text = show_names and utf8_filenames[i], stoppable = true, + width = not show_names and not CURSES and 400 }, function() local f = io.open(filenames[i], 'rb') buffer:set_text(f:read('a')) @@ -351,7 +358,7 @@ function M.find_in_files(dir, filter) view:scroll_caret() -- [Files Found Buffer] i = i + 1 if i > #filenames then return nil end - return i * 100 / #filenames, utf8_filenames[i] + return i * 100 / #filenames, show_names and utf8_filenames[i] or nil end) buffer:close(true) -- temporary buffer local status = stopped and _L['Find in Files aborted'] or not found and _L['No results found'] -- cgit v1.2.3