aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2022-03-07 11:32:49 -0500
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2022-03-07 11:32:49 -0500
commit937573720058266869cdddf0d6f881ee4f706381 (patch)
tree6adcff49b992e8710df5de5b346a8cdc6ba6e18d
parent09d92228f0af9aff66e0eab1bf489457f1e57bb9 (diff)
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.
-rw-r--r--modules/textadept/find.lua13
1 files 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']