summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script-beta/core/completion.lua25
-rw-r--r--script-beta/vm/getDocs.lua38
2 files changed, 41 insertions, 22 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 421ccf90..8ff374b7 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -367,29 +367,10 @@ local function isDeprecated(value)
if doc.type == 'doc.deprecated' then
return true
elseif doc.type == 'doc.version' then
- local ver, jit
- if config.config.runtime.version == 'LuaJIT' then
- ver = 5.1
- jit = true
- else
- ver = tonumber(config.config.runtime.version:sub(-3))
- jit = false
- if not ver then
- return true
- end
+ local valids = vm.getValidVersions(doc)
+ if not valids[config.config.runtime.version] then
+ return true
end
- for _, version in ipairs(doc.versions) do
- if version.ge and ver >= version.version then
- return false
- elseif version.le and ver <= version.version then
- return false
- elseif ver == version.version then
- return false
- elseif jit and 'JIT' == version.version then
- return false
- end
- end
- return true
end
end
return false
diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua
index 75f74028..ef29dcdb 100644
--- a/script-beta/vm/getDocs.lua
+++ b/script-beta/vm/getDocs.lua
@@ -133,3 +133,41 @@ function vm.isMetaFile(uri)
end
return false
end
+
+function vm.getValidVersions(doc)
+ if doc.type ~= 'doc.version' then
+ return
+ end
+ local valids = {
+ ['Lua 5.1'] = false,
+ ['Lua 5.2'] = false,
+ ['Lua 5.3'] = false,
+ ['Lua 5.4'] = false,
+ ['LuaJIT'] = false,
+ }
+ for _, version in ipairs(doc.versions) do
+ if version.ge and type(version.version) == 'number' then
+ for ver in pairs(valids) do
+ local verNumber = tonumber(ver:sub(-3))
+ if verNumber and verNumber >= version.version then
+ valids[ver] = true
+ end
+ end
+ elseif version.le and type(version.version) == 'number' then
+ for ver in pairs(valids) do
+ local verNumber = tonumber(ver:sub(-3))
+ if verNumber and verNumber <= version.version then
+ valids[ver] = true
+ end
+ end
+ elseif type(version.version) == 'number' then
+ valids[('Lua %.1f'):format(version.version)] = true
+ elseif 'JIT' == version.version then
+ valids['LuaJIT'] = true
+ end
+ end
+ if valids['Lua 5.1'] then
+ valids['LuaJIT'] = true
+ end
+ return valids
+end