Go back to `common.match_pattern` and use `table.unpack` directly on function `core.add_thread`
This commit is contained in:
parent
22d8f69b5c
commit
13adedb23a
|
@ -1,5 +1,3 @@
|
||||||
local config = require 'core.config'
|
|
||||||
|
|
||||||
local common = {}
|
local common = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +22,7 @@ function common.merge(a, b)
|
||||||
for k, v in pairs(a) do t[k] = v end
|
for k, v in pairs(a) do t[k] = v end
|
||||||
if b then for k, v in pairs(b) do t[k] = v end end
|
if b then for k, v in pairs(b) do t[k] = v end end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function common.round(n)
|
function common.round(n)
|
||||||
|
@ -447,15 +445,5 @@ function common.rm(path, recursively)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param filename string
|
|
||||||
---@return boolean
|
|
||||||
function common.match_ignore_files(filename)
|
|
||||||
for _, pattern in ipairs(config.ignore_files) do
|
|
||||||
if common.match_pattern(filename, pattern) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return common
|
return common
|
||||||
|
|
|
@ -6,7 +6,7 @@ config.message_timeout = 5
|
||||||
config.mouse_wheel_scroll = 50 * SCALE
|
config.mouse_wheel_scroll = 50 * SCALE
|
||||||
config.scroll_past_end = true
|
config.scroll_past_end = true
|
||||||
config.file_size_limit = 10
|
config.file_size_limit = 10
|
||||||
config.ignore_files = { "^%.", "node_modules" }
|
config.ignore_files = { "^%." }
|
||||||
config.symbol_pattern = "[%a_][%w_]*"
|
config.symbol_pattern = "[%a_][%w_]*"
|
||||||
config.non_word_chars = " \t\n/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-"
|
config.non_word_chars = " \t\n/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-"
|
||||||
config.undo_merge_timeout = 0.3
|
config.undo_merge_timeout = 0.3
|
||||||
|
@ -32,11 +32,11 @@ config.max_clicks = 3
|
||||||
|
|
||||||
config.plugins = {}
|
config.plugins = {}
|
||||||
-- Allow you to set plugin configs even if we haven't seen the plugin before.
|
-- Allow you to set plugin configs even if we haven't seen the plugin before.
|
||||||
setmetatable(config.plugins, {
|
setmetatable(config.plugins, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
if rawget(t, k) == nil then rawset(t, k, {}) end
|
if rawget(t, k) == nil then rawset(t, k, {}) end
|
||||||
return rawget(t, k)
|
return rawget(t, k)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Disable these plugins by default.
|
-- Disable these plugins by default.
|
||||||
|
|
|
@ -100,7 +100,7 @@ local function get_project_file_info(root, file)
|
||||||
if info then
|
if info then
|
||||||
info.filename = strip_leading_path(file)
|
info.filename = strip_leading_path(file)
|
||||||
return (info.size < config.file_size_limit * 1e6 and
|
return (info.size < config.file_size_limit * 1e6 and
|
||||||
not common.match_ignore_files(common.basename(info.filename))
|
not common.match_pattern(common.basename(info.filename), config.ignore_files)
|
||||||
and info)
|
and info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -462,7 +462,7 @@ end
|
||||||
|
|
||||||
local function project_scan_add_file(dir, filepath)
|
local function project_scan_add_file(dir, filepath)
|
||||||
for fragment in string.gmatch(filepath, "([^/\\]+)") do
|
for fragment in string.gmatch(filepath, "([^/\\]+)") do
|
||||||
if common.match_ignore_files(fragment) then
|
if common.match_pattern(fragment, config.ignore_files) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -956,8 +956,7 @@ end
|
||||||
function core.add_thread(f, weak_ref, ...)
|
function core.add_thread(f, weak_ref, ...)
|
||||||
local key = weak_ref or #core.threads + 1
|
local key = weak_ref or #core.threads + 1
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local table_unpack = rawget(_G, 'unpack') or rawget(_G.table, 'unpack')
|
local fn = function() return core.try(f, table.unpack(args)) end
|
||||||
local fn = function() return core.try(f, table_unpack(args)) end
|
|
||||||
core.threads[key] = { cr = coroutine.create(fn), wake = 0 }
|
core.threads[key] = { cr = coroutine.create(fn), wake = 0 }
|
||||||
return key
|
return key
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue