Fix string component containging ['{] taking long to load

This commit is contained in:
shadmansaleh 2021-08-20 09:54:18 +06:00
parent 849d6acc66
commit 6c99ba6ba7
2 changed files with 7 additions and 0 deletions

View File

@ -1,8 +1,10 @@
-- Copyright (c) 2020-2021 hoob3rt -- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local notice = require'lualine.utils.notices' local notice = require'lualine.utils.notices'
local utils = require'lualine.utils.utils'
local function lualine_load(patern, use_cache) local function lualine_load(patern, use_cache)
assert(utils.is_valid_filename(patern[#patern]), "Invalid filename")
local retval, cache_name = nil, nil local retval, cache_name = nil, nil
local sep = package.config:sub(1,1) local sep = package.config:sub(1,1)

View File

@ -75,4 +75,9 @@ function M.is_focused()
return tonumber(vim.g.actual_curwin) == vim.fn.win_getid() return tonumber(vim.g.actual_curwin) == vim.fn.win_getid()
end end
function M.is_valid_filename(name)
local invalid_chars="[^a-zA-Z0-9_. ]"
return name:find(invalid_chars) == nil
end
return M return M