summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-09 21:25:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-09 21:25:35 +0800
commit96c870c5b91e724b4a291c857fd2300706017d8a (patch)
treecb595b0f330578b6979a754be3c1fa19e977b3ef
parent6446cf30edaf099d338859b9eb858d2a1058e542 (diff)
downloadlua-language-server-96c870c5b91e724b4a291c857fd2300706017d8a.zip
修正 library 文件打开关闭后会从文件表中移除的bug
-rw-r--r--script-beta/workspace/workspace.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua
index 041379f7..a0fc7615 100644
--- a/script-beta/workspace/workspace.lua
+++ b/script-beta/workspace/workspace.lua
@@ -115,7 +115,7 @@ function m.getNativeMatcher()
end
--- 创建代码库筛选器
-function m.getLibraryMatchers(option)
+function m.getLibraryMatchers()
if m.libraryVersion == config.version then
return m.libraryMatchers
end
@@ -123,7 +123,7 @@ function m.getLibraryMatchers(option)
m.libraryMatchers = {}
for path, pattern in pairs(config.config.workspace.library) do
local nPath = fs.absolute(fs.path(path)):string()
- local matcher = glob.gitignore(pattern, option)
+ local matcher = glob.gitignore(pattern, m.matchOption)
if platform.OS == 'Windows' then
matcher:setOption 'ignoreCase'
end
@@ -145,6 +145,13 @@ function m.isIgnored(uri)
return ignore(path)
end
+--- 文件是否作为库被加载
+function m.isLibrary(uri)
+ local path = furi.decode(uri)
+ local ignore = m.getLibraryMatchers()
+ return ignore(path)
+end
+
local function loadFileFactory(root, progress, isLibrary)
return function (path)
local uri = furi.encode(root .. '/' .. path)
@@ -191,7 +198,7 @@ function m.awaitPreload()
log.info('Preload start.')
local nativeLoader = loadFileFactory(m.path, progress)
local native = m.getNativeMatcher()
- local librarys = m.getLibraryMatchers(m.matchOption)
+ local librarys = m.getLibraryMatchers()
native:scan(nativeLoader)
for _, library in ipairs(librarys) do
local libraryInterface = interfaceFactory(library.path)
@@ -296,7 +303,9 @@ function m.reload()
end
files.watch(function (ev, uri)
- if ev == 'close' and m.isIgnored(uri) then
+ if ev == 'close'
+ and m.isIgnored(uri)
+ and not m.isLibrary(uri) then
files.remove(uri)
end
end)