summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/parser/guide.lua20
-rw-r--r--test/crossfile/definition.lua22
3 files changed, 36 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md
index 2602bc2d..985de9d2 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,7 @@
# changelog
## 1.14.2
+* `FIX` [#356](https://github.com/sumneko/lua-language-server/issues/356)
* `FIX` [#375](https://github.com/sumneko/lua-language-server/issues/375)
* `FIX` [#376](https://github.com/sumneko/lua-language-server/issues/376)
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 0ceb4d3f..18a2403d 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -2650,10 +2650,22 @@ function m.searchSameFields(status, simple, mode)
local queues, starts, forces = allocQueue()
local queueLen = 0
local function pushQueue(obj, start, force)
+ if obj.type == 'getlocal'
+ or obj.type == 'setlocal' then
+ obj = obj.node
+ end
queueLen = queueLen + 1
queues[queueLen] = obj
starts[queueLen] = start
forces[queueLen] = force
+ if obj.type == 'local' and obj.ref then
+ for _, ref in ipairs(obj.ref) do
+ queueLen = queueLen + 1
+ queues[queueLen] = ref
+ starts[queueLen] = start
+ forces[queueLen] = force
+ end
+ end
end
if simple.mode == 'global' then
-- 全局变量开头
@@ -2661,12 +2673,6 @@ function m.searchSameFields(status, simple, mode)
elseif simple.mode == 'local' then
-- 局部变量开头
pushQueue(simple.node, 1)
- local refs = simple.node.ref
- if refs then
- for i = 1, #refs do
- pushQueue(refs[i], 1)
- end
- end
else
pushQueue(simple.node, 1)
end
@@ -4409,7 +4415,7 @@ function m.requestInfer(obj, interface, deep)
end
function m.debugView(obj)
- return require 'files'.position(m.getUri(obj), obj.start)
+ return require 'files'.position(m.getUri(obj), obj.start), m.getUri(obj)
end
return m
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index 30d796c8..0eb6888f 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -640,3 +640,25 @@ TEST {
]]
},
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local m = {}
+
+ function m.<!f!>()
+ end
+
+ return setmetatable(m, {})
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local m = require 'a'
+
+ m.<?f?>()
+ ]]
+ }
+}