summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/method/initialized.lua6
-rw-r--r--server/src/method/workspace/didChangeWatchedFiles.lua7
-rw-r--r--server/src/service.lua2
-rw-r--r--server/src/workspace.lua21
-rw-r--r--server/test/crossfile/completion.lua2
-rw-r--r--server/test/crossfile/definition.lua2
-rw-r--r--server/test/crossfile/document_symbol.lua4
-rw-r--r--server/test/crossfile/hover.lua4
-rw-r--r--server/test/crossfile/references.lua2
9 files changed, 29 insertions, 21 deletions
diff --git a/server/src/method/initialized.lua b/server/src/method/initialized.lua
index ab05c2b3..05abffd7 100644
--- a/server/src/method/initialized.lua
+++ b/server/src/method/initialized.lua
@@ -16,9 +16,9 @@ local function initAfterConfig(lsp, firstScope)
registerOptions = {
watchers = {
{
- globPattern = '**/*.lua',
- kind = 1 | 4, -- Create | Change | Delete
- },
+ globPattern = '**/',
+ kind = 1 | 4,
+ }
},
},
},
diff --git a/server/src/method/workspace/didChangeWatchedFiles.lua b/server/src/method/workspace/didChangeWatchedFiles.lua
index a5fecac3..7e1afb92 100644
--- a/server/src/method/workspace/didChangeWatchedFiles.lua
+++ b/server/src/method/workspace/didChangeWatchedFiles.lua
@@ -1,3 +1,5 @@
+local fs = require 'bee.filesystem'
+
local FileChangeType = {
Created = 1,
Changed = 2,
@@ -10,10 +12,11 @@ return function (lsp, params)
end
local needReset
for _, change in ipairs(params.changes) do
+ local path = lsp.workspace:uriDecode(change.uri)
if change.type == FileChangeType.Created then
- lsp.workspace:addFile(change.uri)
+ lsp.workspace:addFile(path)
elseif change.type == FileChangeType.Deleted then
- lsp.workspace:removeFile(change.uri)
+ lsp.workspace:removeFile(path)
end
if lsp:getVM(change.uri) then
needReset = true
diff --git a/server/src/service.lua b/server/src/service.lua
index 9db272af..81b5b98e 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -826,7 +826,7 @@ function mt:_testMemory()
))
log.debug('test memory: ', ('%.3f'):format(os.clock() - clock))
- self:_testDeadValue()
+ --self:_testDeadValue()
end
function mt:onTick()
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index 9920964f..87cc4c98 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -205,18 +205,23 @@ function mt:isLuaFile(path)
return false
end
-function mt:addFile(uri)
- local path = self:uriDecode(uri)
- if self:isLuaFile(path) then
- local name = getFileName(path)
- self.files[name] = uri
- self.lsp:readText(uri, path)
+function mt:addFile(path)
+ if not self:isLuaFile(path) then
+ return
end
+ local name = getFileName(path)
+ local uri = self:uriEncode(path)
+ self.files[name] = uri
+ self.lsp:readText(uri, path)
end
-function mt:removeFile(uri)
- local name = getFileName(self:uriDecode(uri))
+function mt:removeFile(path)
+ local name = getFileName(path)
+ if not self.files[name] then
+ return
+ end
self.files[name] = nil
+ local uri = self:uriEncode(path)
self.lsp:removeText(uri)
end
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index 67928fb6..4ee9508e 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -80,7 +80,7 @@ function TEST(data)
mainBuf = script
end
lsp:saveText(uri, 1, script)
- ws:addFile(uri)
+ ws:addFile(ws:uriDecode(uri))
while lsp._needCompile[1] do
lsp:compileVM(lsp._needCompile[1])
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index 9de93c92..90bf1651 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -79,7 +79,7 @@ function TEST(datas)
data.content = new
end
lsp:saveText(uri, 1, data.content)
- ws:addFile(uri)
+ ws:addFile(ws:uriDecode(uri))
end
while lsp._needCompile[1] do
diff --git a/server/test/crossfile/document_symbol.lua b/server/test/crossfile/document_symbol.lua
index 015e3638..e09ed5d1 100644
--- a/server/test/crossfile/document_symbol.lua
+++ b/server/test/crossfile/document_symbol.lua
@@ -71,9 +71,9 @@ function TEST(data)
local sourceUri = ws:uriEncode(fs.path(data[2].path))
lsp:saveText(sourceUri, 1, data[2].content)
- ws:addFile(sourceUri)
+ ws:addFile(ws:uriDecode(sourceUri))
lsp:saveText(targetUri, 1, data[1].content)
- ws:addFile(targetUri)
+ ws:addFile(ws:uriDecode(targetUri))
while lsp._needCompile[1] do
lsp:compileVM(lsp._needCompile[1])
end
diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua
index 41aef8dc..fc5df36a 100644
--- a/server/test/crossfile/hover.lua
+++ b/server/test/crossfile/hover.lua
@@ -63,10 +63,10 @@ function TEST(data)
local sourceUri = ws:uriEncode(fs.path(data[2].path))
lsp:saveText(targetUri, 1, targetScript)
- ws:addFile(targetUri)
+ ws:addFile(ws:uriDecode(targetUri))
lsp:compileVM(targetUri)
lsp:saveText(sourceUri, 1, sourceScript)
- ws:addFile(sourceUri)
+ ws:addFile(ws:uriDecode(sourceUri))
lsp:compileVM(sourceUri)
local sourceVM = lsp:loadVM(sourceUri)
diff --git a/server/test/crossfile/references.lua b/server/test/crossfile/references.lua
index 4163a321..dd1958aa 100644
--- a/server/test/crossfile/references.lua
+++ b/server/test/crossfile/references.lua
@@ -80,7 +80,7 @@ function TEST(data)
local expect = {}
for _, info in ipairs(data) do
local uri = ws:uriEncode(fs.path(info.path))
- ws:addFile(uri)
+ ws:addFile(ws:uriDecode(uri))
end
for _, info in ipairs(data) do
local uri = ws:uriEncode(fs.path(info.path))