summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-28 17:54:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-28 17:54:49 +0800
commit21f4c487be07960ffeac86e6842c5e159333e71c (patch)
tree130ebe1b0c21fd4716e2c2e07daa6649b1bc7a1d
parentc427477428c0c1d583f42c0e7784684b8f713a6e (diff)
downloadlua-language-server-21f4c487be07960ffeac86e6842c5e159333e71c.zip
特殊处理一下后置斜杠
-rw-r--r--server/src/async/scanfiles.lua37
-rw-r--r--server/src/path_filter.lua3
2 files changed, 25 insertions, 15 deletions
diff --git a/server/src/async/scanfiles.lua b/server/src/async/scanfiles.lua
index a9c266b3..6783f97b 100644
--- a/server/src/async/scanfiles.lua
+++ b/server/src/async/scanfiles.lua
@@ -5,8 +5,14 @@ local fs = require 'bee.filesystem'
local path_filter = require 'path_filter'
local function scan(root, filter)
- local len = #root
- local result = {fs.path(root)}
+ local result = {}
+ local len = #root:string()
+ local name = root:string():sub(len+2):gsub('/', '\\')
+ if filter(name) then
+ OUT:push('log', '过滤文件:', root:string())
+ else
+ result[#result+1] = root
+ end
local i = 0
return function ()
i = i + 1
@@ -15,17 +21,12 @@ local function scan(root, filter)
return nil
end
if fs.is_directory(current) then
- local name = current:string():sub(len+2):gsub('/', '\\')
- if filter(name) then
- OUT:push('log', '过滤目录:', current:string())
- else
- for path in current:list_directory() do
- local name = path:string():sub(len+2):gsub('/', '\\')
- if filter(name) then
- OUT:push('log', '过滤文件:', path:string())
- else
- result[#result+1] = path
- end
+ for path in current:list_directory() do
+ local name = path:string():sub(len+2):gsub('/', '\\')
+ if filter(name) then
+ OUT:push('log', '过滤文件:', path:string())
+ else
+ result[#result+1] = path
end
end
end
@@ -33,8 +34,14 @@ local function scan(root, filter)
end
end
-local filter = path_filter(args.ignored)
-for path in scan(args.root, filter) do
+local ignore = {}
+for _, name in ipairs(args.ignored) do
+ if name:sub(1, 1) ~= '!' then
+ ignore[#ignore+1] = name
+ end
+end
+local filter = path_filter(ignore)
+for path in scan(fs.path(args.root), filter) do
if path:extension():string() == '.lua' then
local buf = io.load(path)
if buf then
diff --git a/server/src/path_filter.lua b/server/src/path_filter.lua
index 2a362677..fb39a6f8 100644
--- a/server/src/path_filter.lua
+++ b/server/src/path_filter.lua
@@ -25,6 +25,9 @@ local function compile_exp(exp)
else
exp = '**/' .. exp
end
+ if exp:sub(-1) == '/' then
+ exp = exp:sub(1, -2)
+ end
local function next(cur)
local pos, fn = exp:find('[/\\]+', cur)
if not pos then