summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-01-23 19:24:49 +0800
committersumneko <sumneko@hotmail.com>2022-01-23 19:24:49 +0800
commit7fc0bde24d7ba080988b5bba6faf227376191ddc (patch)
tree6f06f895ba2687a85a7259b2c5135013104ca039
parent48f59772c3fdf2fdc5a250f8f770ad16f1f0b3ab (diff)
downloadlua-language-server-7fc0bde24d7ba080988b5bba6faf227376191ddc.zip
diagnostic check file as folder before as library
-rw-r--r--script/core/rename.lua2
-rw-r--r--script/files.lua9
-rw-r--r--script/provider/diagnostic.lua4
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