summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-23 18:32:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-23 18:32:21 +0800
commit73fb79c13e846774b99d3c0dab886c639611ed48 (patch)
treea1511caa98853cc804171d44c91e99b0121ec752
parent57c107a0ae92086b4cf2605efb8c108a525053f5 (diff)
downloadlua-language-server-73fb79c13e846774b99d3c0dab886c639611ed48.zip
不会require自己
-rw-r--r--script-beta/vm/guideInterface.lua19
1 files 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