summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-04 16:39:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-04 16:39:49 +0800
commit6e7c082aa3e1011cdecd1761f7d04eabc0e2b8ba (patch)
treebbb69bdde3ef94b47269d18251834637873428a3 /script
parent9699b6c6f6ee1ce658bc93343479b5271c18b7f4 (diff)
downloadlua-language-server-6e7c082aa3e1011cdecd1761f7d04eabc0e2b8ba.zip
fix #377 watched file must check workspace
Diffstat (limited to 'script')
-rw-r--r--script/provider/provider.lua4
-rw-r--r--script/workspace/workspace.lua6
2 files changed, 10 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index a7927715..71649a2f 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -157,6 +157,9 @@ end)
proto.on('workspace/didChangeWatchedFiles', function (params)
for _, change in ipairs(params.changes) do
local uri = change.uri
+ if not workspace.isWorkspaceUri(uri) then
+ goto CONTINUE
+ end
if change.type == define.FileChangeType.Created then
log.debug('FileChangeType.Created', uri)
workspace.awaitLoadFile(uri)
@@ -184,6 +187,7 @@ proto.on('workspace/didChangeWatchedFiles', function (params)
end
end
end
+ ::CONTINUE::
end
end)
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 667a05f2..88451940 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -434,6 +434,12 @@ function m.getRelativePath(uri)
end
end
+function m.isWorkspaceUri(uri)
+ local luri = files.getUri(uri)
+ local ruri = files.getUri(m.uri)
+ return luri:sub(1, #ruri) == ruri
+end
+
--- 获取工作区等级的缓存
function m.getCache(name)
if not m.cache[name] then