diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 10:30:29 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 10:30:29 +0800 |
commit | f40f74a27e3853bbd027e63d6a3e3660e8071316 (patch) | |
tree | 8175a7667ff03aa2a62f692db36a49e7f2e0ece6 | |
parent | af44e932a9d73a43b5d6524712856b3e5c1ca462 (diff) | |
download | lua-language-server-f40f74a27e3853bbd027e63d6a3e3660e8071316.zip |
Merge保护
-rw-r--r-- | server/src/matcher/vm.lua | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index b73aa100..acf06f98 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -239,19 +239,35 @@ function mt:mergeChild(a, b, mark) if not mark then mark = {} end - local child = a.child or orderTable() - local other = b.child or orderTable() - a.child = nil - b.child = nil - for k, v in pairs(other) do - if child[k] then - self:mergeField(child[k], v, mark) - else + if a.uri ~= self.uri then + return + end + if b.uri == self.uri then + local child = a.child or orderTable() + local other = b.child or orderTable() + a.child = nil + b.child = nil + for k, v in pairs(other) do + if child[k] then + self:mergeField(child[k], v, mark) + else + child[k] = v + end + end + a.child = child + b.child = child + else + local child = a.child or orderTable() + local other = b.child + if not other then + return + end + a.child = nil + for k, v in pairs(other) do child[k] = v end + a.child = child end - a.child = child - b.child = child end function mt:setValue(var, value, source) |