diff options
-rw-r--r-- | core/locale.conf | 8 | ||||
-rw-r--r-- | modules/textadept/snapopen.lua | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/locale.conf b/core/locale.conf index 7de8701a..d6df2c3f 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -658,3 +658,11 @@ M_SESSION_FILES_NOT_FOUND_TITLE "Session Files Not Found" % modules/textadept/session.lua % "The following session files were not found" M_SESSION_FILES_NOT_FOUND_TEXT "The following session files were not found" + +% modules/textadept/snapopen.lua +% "File Limit Exceeded" +M_SNAPOPEN_LIMIT_EXCEEDED_TITLE "File Limit Exceeded" + +% modules/textadept/snapopen.lua +% "%s files or more were found. Showing the first %s." +M_SNAPOPEN_LIMIT_EXCEEDED_TEXT "%s files or more were found. Showing the first %s." diff --git a/modules/textadept/snapopen.lua b/modules/textadept/snapopen.lua index 43da3f6e..56afcaa1 100644 --- a/modules/textadept/snapopen.lua +++ b/modules/textadept/snapopen.lua @@ -11,6 +11,7 @@ module('_m.textadept.snapopen', package.seeall) --
-- * `PATHS`: Table of default paths to search.
-- * `DEPTH`: Maximum directory depth to search (defaults to 4).
+-- * `MAX`: Maximum number of files to list (defaults to 1000).
--
-- ## Examples
--
@@ -32,6 +33,7 @@ module('_m.textadept.snapopen', package.seeall) -- settings
PATHS = {}
DEPTH = 4
+MAX = 1000
-- end settings
local lfs = require 'lfs'
@@ -69,6 +71,7 @@ local function add_directory(dir, list, depth, filter) add_directory(file, list, depth + 1, filter)
end
elseif not exclude(file, filter) then
+ if #list >= MAX then return end
list[#list + 1] = string_gsub(file, '^%.[/\\]', '')
end
end
@@ -99,6 +102,12 @@ function open(paths, filter, exclusive) end
local list = {}
for _, path in ipairs(paths) do add_directory(path, list, 1, filter) end
+ if #list >= MAX then
+ gui.dialog('ok-msgbox',
+ '--title', locale.M_SNAPOPEN_LIMIT_EXCEEDED_TITLE,
+ '--informative-text',
+ string.format(locale.M_SNAPOPEN_LIMIT_EXCEEDED_TEXT, MAX, MAX))
+ end
local out =
gui.dialog('filteredlist',
'--title', locale.IO_OPEN_TITLE,
|