From 96c870c5b91e724b4a291c857fd2300706017d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 9 Nov 2020 21:25:35 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20library=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=85=B3=E9=97=AD=E5=90=8E=E4=BC=9A=E4=BB=8E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=A1=A8=E4=B8=AD=E7=A7=BB=E9=99=A4=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/workspace/workspace.lua | 17 +++++++++++++---- 1 file 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) -- cgit v1.2.3