From 73fb79c13e846774b99d3c0dab886c639611ed48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 23 Jul 2020 18:32:21 +0800 Subject: =?UTF-8?q?=E4=B8=8D=E4=BC=9Arequire=E8=87=AA=E5=B7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/vm/guideInterface.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/script-beta/vm/guideInterface.lua b/script-beta/vm/guideInterface.lua index 37d47c35..ca949d59 100644 --- a/script-beta/vm/guideInterface.lua +++ b/script-beta/vm/guideInterface.lua @@ -1,6 +1,7 @@ local vm = require 'vm.vm' local files = require 'files' local ws = require 'workspace' +local guide = require 'parser.guide' local m = {} @@ -29,11 +30,14 @@ function m.require(args, index) return nil end local results = {} + local myUri = guide.getRoot(args[1]).uri local uris = ws.findUrisByRequirePath(reqName, true) for _, uri in ipairs(uris) do - local ast = files.getAst(uri) - if ast then - m.searchFileReturn(results, ast.ast, index) + if not files.eq(myUri, uri) then + local ast = files.getAst(uri) + if ast then + m.searchFileReturn(results, ast.ast, index) + end end end return results @@ -45,11 +49,14 @@ function m.dofile(args, index) return end local results = {} + local myUri = guide.getRoot(args[1]).uri local uris = ws.findUrisByFilePath(reqName, true) for _, uri in ipairs(uris) do - local ast = files.getAst(uri) - if ast then - m.searchFileReturn(results, ast.ast, index) + if not files.eq(myUri, uri) then + local ast = files.getAst(uri) + if ast then + m.searchFileReturn(results, ast.ast, index) + end end end return results -- cgit v1.2.3