summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authorunknown <sumnekosun@intranet.123u.com>2019-04-02 11:49:54 +0800
committerunknown <sumnekosun@intranet.123u.com>2019-04-02 11:49:54 +0800
commitb088d81fee88309a7744dd63117a787004ae8a99 (patch)
treea2ae31977a8d43a51976c46c3d2544cc2d41c627 /server/src
parenta485c7f464f2abb91311565c2f1078b5d381f808 (diff)
downloadlua-language-server-b088d81fee88309a7744dd63117a787004ae8a99.zip
自动完成不再过滤完全相同的值
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/completion.lua18
-rw-r--r--server/src/utility.lua15
2 files changed, 25 insertions, 8 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 23bd224c..cf9a1a90 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -222,6 +222,16 @@ local function searchFields(vm, source, word, callback)
if source:get 'object' and v:getType() ~= 'function' then
goto CONTINUE
end
+ if k == word then
+ local ok = v:eachInfo(function (_, src)
+ if src ~= source then
+ return true
+ end
+ end)
+ if not ok then
+ goto CONTINUE
+ end
+ end
if matchKey(word, k) then
map[k] = v
end
@@ -509,7 +519,7 @@ local function searchSpecial(vm, source, word, callback, pos)
end
end
-local function makeList(source, word)
+local function makeList(source, pos, word)
local list = {}
local mark = {}
return function (name, src, kind, data)
@@ -517,7 +527,9 @@ local function makeList(source, word)
return
end
if word == name then
- return
+ if src and src.start <= pos and src.finish >= pos then
+ return
+ end
end
if mark[name] then
return
@@ -547,7 +559,7 @@ return function (vm, pos, word, oldText)
return nil
end
end
- local callback, list = makeList(source, word)
+ local callback, list = makeList(source, pos, word)
searchSpecial(vm, source, word, callback, pos)
searchCallArg(vm, source, word, callback, pos)
searchSource(vm, source, word, callback)
diff --git a/server/src/utility.lua b/server/src/utility.lua
index 3f0df110..a4072510 100644
--- a/server/src/utility.lua
+++ b/server/src/utility.lua
@@ -10,6 +10,8 @@ local next = next
local rawset = rawset
local move = table.move
local setmetatable = setmetatable
+local tableSort = table.sort
+local mathType = math.type
local TAB = setmetatable({}, { __index = function (self, n)
self[n] = string_rep('\t', n)
@@ -41,16 +43,19 @@ function table.dump(tbl)
else
KEY[key] = key
end
- elseif math_type(key) == 'integer' then
- KEY[key] = ('[%d]'):format(key)
+ elseif mathType(key) == 'integer' then
+ KEY[key] = ('[%03d]'):format(key)
else
KEY[key] = ('<%s>'):format(key)
end
keys[#keys+1] = key
end
- table_sort(keys, function (a, b)
- return KEY[a] < KEY[b]
- end)
+ local mt = getmetatable(tbl)
+ if not mt or not mt.__pairs then
+ tableSort(keys, function (a, b)
+ return KEY[a] < KEY[b]
+ end)
+ end
for _, key in ipairs(keys) do
local value = tbl[key]
local tp = type(value)