From 7fc0bde24d7ba080988b5bba6faf227376191ddc Mon Sep 17 00:00:00 2001 From: sumneko Date: Sun, 23 Jan 2022 19:24:49 +0800 Subject: diagnostic check file as folder before as library --- script/core/rename.lua | 2 +- script/files.lua | 9 ++++++++- script/provider/diagnostic.lua | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/script/core/rename.lua b/script/core/rename.lua index d90a49bb..69021197 100644 --- a/script/core/rename.lua +++ b/script/core/rename.lua @@ -354,7 +354,7 @@ function m.rename(uri, pos, newname) return end mark[uid] = true - if files.isLibrary(turi) then + if files.isLibrary(turi, true) then return end results[#results+1] = { diff --git a/script/files.lua b/script/files.lua index 03ce47c2..bd7ae819 100644 --- a/script/files.lua +++ b/script/files.lua @@ -108,7 +108,14 @@ function m.setLibraryUri(scp, uri, libraryUri) end --- 是否是库文件 -function m.isLibrary(uri) +function m.isLibrary(uri, excludeFolder) + if excludeFolder then + for _, scp in ipairs(scope.folders) do + if scp:isChildUri(uri) then + return false + end + end + end for _, scp in ipairs(scope.folders) do local map = scp:get 'libraryMap' if map and map[uri] ~= nil then diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 676bc6c5..2ca5830d 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -187,7 +187,7 @@ function m.doDiagnostic(uri, isScopeDiag) if not config.get(uri, 'Lua.diagnostics.enable') then return end - if files.isLibrary(uri) then + if files.isLibrary(uri, true) then local status = config.get(uri, 'Lua.diagnostics.libraryFiles') if status == 'Disable' then return @@ -411,7 +411,7 @@ files.watch(function (ev, uri) ---@async xpcall(m.doDiagnostic, log.error, uri) end elseif ev == 'close' then - if files.isLibrary(uri) + if files.isLibrary(uri, true) or ws.isIgnored(uri) then m.clear(uri) end -- cgit v1.2.3