From 2dacca7b19ba0162975c7f2da2dd5e9381b4a73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 13 Sep 2020 19:11:17 +0800 Subject: =?UTF-8?q?=E4=B8=8D=E8=83=BDrequire=E8=87=AA=E5=B7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/completion.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'script-beta/core') 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 -- cgit v1.2.3