summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-08 14:57:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-08 14:57:08 +0800
commit516d72e03cd193316b2d9630383581e7a352633c (patch)
tree00993fe883536218851b1e8f3dc19ae9941e13d9 /script/vm
parent3e0577f4ef0d8efdaeb0167551882eb9877af95c (diff)
downloadlua-language-server-516d72e03cd193316b2d9630383581e7a352633c.zip
`LuaDoc` supports `---@diagnostic disable`
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/getDocs.lua25
1 files changed, 24 insertions, 1 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 05ecfdd3..1bf27859 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -245,7 +245,8 @@ local function makeDiagRange(uri, doc, results)
if doc.names then
names = {}
for i, nameUnit in ipairs(doc.names) do
- names[i] = nameUnit[1]
+ local name = nameUnit[1]
+ names[name] = true
end
end
local row = guide.positionOf(lines, doc.start)
@@ -318,4 +319,26 @@ function vm.isDiagDisabledAt(uri, offset, name)
return a.offset < b.offset
end)
end
+ if #cache.diagnosticRanges == 0 then
+ return false
+ end
+ local stack = {}
+ for _, range in ipairs(cache.diagnosticRanges) do
+ if range.offset <= offset then
+ if not range.names or range.names[name] then
+ if range.mode == 'disable' then
+ stack[#stack+1] = range
+ elseif range.mode == 'enable' then
+ stack[#stack] = nil
+ end
+ end
+ else
+ break
+ end
+ end
+ local current = stack[#stack]
+ if not current then
+ return false
+ end
+ return true
end