diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/files.lua | 13 | ||||
-rw-r--r-- | script-beta/library.lua | 14 | ||||
-rw-r--r-- | script-beta/workspace/workspace.lua | 17 |
3 files changed, 20 insertions, 24 deletions
diff --git a/script-beta/files.lua b/script-beta/files.lua index 06e598ee..2d2f00da 100644 --- a/script-beta/files.lua +++ b/script-beta/files.lua @@ -174,10 +174,12 @@ function m.removeAll() m.globalVersion = m.globalVersion + 1 await.close('files.version') for uri in pairs(m.fileMap) do - m.fileMap[uri] = nil - m.astMap[uri] = nil - m.linesMap[uri] = nil - m.onWatch('remove', uri) + if not m.libraryMap[uri] then + m.fileMap[uri] = nil + m.astMap[uri] = nil + m.linesMap[uri] = nil + m.onWatch('remove', uri) + end end --m.notifyCache = {} end @@ -187,7 +189,8 @@ function m.removeAllClosed() m.globalVersion = m.globalVersion + 1 await.close('files.version') for uri in pairs(m.fileMap) do - if not m.openMap[uri] then + if not m.openMap[uri] + and not m.libraryMap[uri] then m.fileMap[uri] = nil m.astMap[uri] = nil m.linesMap[uri] = nil diff --git a/script-beta/library.lua b/script-beta/library.lua index a4741fd1..c9cfe32d 100644 --- a/script-beta/library.lua +++ b/script-beta/library.lua @@ -310,19 +310,23 @@ end local function compileMetaDoc() local langID = lang.id local version = config.config.runtime.version - m.metapath = ROOT / 'meta' / config.config.runtime.meta:gsub('%$%{(.-)%}', { + local metapath = ROOT / 'meta' / config.config.runtime.meta:gsub('%$%{(.-)%}', { version = version, language = langID, }) - if fs.exists(m.metapath) then + if fs.exists(metapath) then --return end - fs.create_directory(m.metapath) + m.metaPath = metapath:string() + m.metaPaths = {} + fs.create_directory(metapath) local templateDir = ROOT / 'meta' / 'template' for fullpath in templateDir:list_directory() do local filename = fullpath:filename() local metaDoc = compileSingleMetaDoc(util.loadFile(fullpath:string())) - util.saveFile((m.metapath / filename):string(), metaDoc) + local filepath = metapath / filename + util.saveFile(filepath:string(), metaDoc) + m.metaPaths[#m.metaPaths+1] = filepath:string() end end @@ -373,7 +377,7 @@ local function initFromMetaDoc() end local function init() - if DEVELOP then + if DEVELOP or TEST then initFromMetaDoc() else initFromLni() diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua index 0050e299..ce8cf161 100644 --- a/script-beta/workspace/workspace.lua +++ b/script-beta/workspace/workspace.lua @@ -125,8 +125,8 @@ function m.getLibraryMatchers() for path, pattern in pairs(config.config.workspace.library) do librarys[path] = pattern end - if library.metapath then - librarys[library.metapath] = true + if library.metaPath then + librarys[library.metaPath] = true end m.libraryMatchers = {} for path, pattern in pairs(librarys) do @@ -153,17 +153,6 @@ function m.isIgnored(uri) return ignore(path) end ---- 文件是否作为库被加载 -function m.isLibrary(uri) - local path = furi.decode(uri) - for _, library in ipairs(m.getLibraryMatchers()) do - if library.matcher(path) then - return true - end - end - return false -end - local function loadFileFactory(root, progress, isLibrary) return function (path) local uri = furi.encode(root .. '/' .. path) @@ -317,7 +306,7 @@ end files.watch(function (ev, uri) if ev == 'close' and m.isIgnored(uri) - and not m.isLibrary(uri) then + and not files.isLibrary(uri) then files.remove(uri) end end) |