From 9e8901c5d09b4537a5741fd20dc5cc77c5a23dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 18 Jan 2022 17:02:45 +0800 Subject: `FIX` library files not recognized correctly --- script/files.lua | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'script/files.lua') diff --git a/script/files.lua b/script/files.lua index 3ec942cb..009beba4 100644 --- a/script/files.lua +++ b/script/files.lua @@ -12,6 +12,7 @@ local guide = require 'parser.guide' local smerger = require 'string-merger' local progress = require "progress" local encoder = require 'encoder' +local scope = require 'workspace.scope' ---@class files local m = {} @@ -23,7 +24,6 @@ m.assocMatcher = nil function m.reset() m.openMap = {} - m.libraryMap = {} m.fileMap = {} m.dllMap = {} m.visible = {} @@ -110,12 +110,28 @@ end --- 是否是库文件 function m.isLibrary(uri) - return m.libraryMap[uri] ~= nil + for _, scp in ipairs(scope.folders) do + local map = scp:get 'libraryMap' + if map and map[uri] ~= nil then + return true + end + end + local map = scope.fallback:get 'libraryMap' + if map and map[uri] ~= nil then + return true + end + return false end --- 获取库文件的根目录 function m.getLibraryPath(uri) - return m.libraryMap[uri] + for _, scp in ipairs(scope.folders) do + local map = scp:get 'libraryMap' + if map and map[uri] ~= nil then + return scp.uri + end + end + return nil end ---@param scp scope -- cgit v1.2.3