summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-13 19:11:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-13 19:11:17 +0800
commit2dacca7b19ba0162975c7f2da2dd5e9381b4a73c (patch)
treebb0e727b409adf1fa90a699778a9afe93baab1ef /script-beta/core
parent9c228abd1cccf1b1451c9fee9ffb9962b3f33d82 (diff)
downloadlua-language-server-2dacca7b19ba0162975c7f2da2dd5e9381b4a73c.zip
不能require自己
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 455e257c..ec4b0fe6 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -203,7 +203,7 @@ local function isSameSource(ast, source, pos)
if source.type == 'library' then
return false
end
- if guide.getUri(source) ~= guide.getUri(ast.ast) then
+ if not files.eq(guide.getUri(source), guide.getUri(ast.ast)) then
return false
end
if source.type == 'field'
@@ -463,6 +463,7 @@ end
local function checkUri(ast, text, offset, results)
local collect = {}
+ local myUri = guide.getUri(ast.ast)
guide.eachSourceContain(ast.ast, offset, function (source)
if source.type ~= 'string' then
return
@@ -484,6 +485,9 @@ local function checkUri(ast, text, offset, results)
if lib.name == 'require' then
for uri in files.eachFile() do
uri = files.getOriginUri(uri)
+ if files.eq(myUri, uri) then
+ goto CONTINUE
+ end
local path = workspace.getRelativePath(uri)
local infos = rpath.getVisiblePath(path, config.config.runtime.path)
for _, info in ipairs(infos) do
@@ -504,6 +508,7 @@ local function checkUri(ast, text, offset, results)
)
end
end
+ ::CONTINUE::
end
elseif lib.name == 'dofile'
or lib.name == 'loadfile' then