diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/vm.lua | 22 | ||||
-rw-r--r-- | server/test/crossfile/completion.lua | 38 |
2 files changed, 57 insertions, 3 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 1b098785..e2ea5a15 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -36,8 +36,12 @@ local function orderTable() end local function readOnly(t) + local keys return setmetatable({}, { __index = function (self, k) + if k == nil then + return nil + end local v = t[k] if type(v) == 'table' then v = readOnly(v) @@ -48,6 +52,20 @@ local function readOnly(t) __len = function (self) return #t end, + __pairs = function (self) + if not keys then + keys = {} + for k in pairs(t) do + keys[#keys+1] = k + end + end + local i = 0 + return function () + i = i + 1 + local k = keys[i] + return k, self[k] + end + end, __source = t, }) end @@ -218,9 +236,7 @@ function mt:mergeValue(a, b, mark) end mark[a] = true mark[b] = true - if b.uri == self.uri then - self:mergeChild(a, b, mark) - end + self:mergeChild(a, b, mark) for k in pairs(a) do a[k] = nil end diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua index 15b19176..7d4513ba 100644 --- a/server/test/crossfile/completion.lua +++ b/server/test/crossfile/completion.lua @@ -217,3 +217,41 @@ TEST { }, } } + +TEST { + { + path = 'a.lua', + content = [[ + return { + a = 1, + b = 2, + c = 3, + } + ]] + }, + { + path = 'b.lua', + content = [[ + local t = require 'a' + t.@ + ]], + main = true, + }, + completion = { + { + label = 'a', + kind = CompletionItemKind.Enum, + detail = '= 1', + }, + { + label = 'b', + kind = CompletionItemKind.Enum, + detail = '= 2', + }, + { + label = 'c', + kind = CompletionItemKind.Enum, + detail = '= 3', + }, + } +} |