summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md11
-rw-r--r--script/files.lua14
-rw-r--r--script/provider/provider.lua21
3 files changed, 39 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md
index 381505cf..27ae4251 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,16 +1,17 @@
# changelog
## 1.14.0
-* `NEW` hint
+* `NEW` `VSCode` hint
* `NEW` flush cache after 5 min
-* `NEW` help semantic color with market theme
-* `FIX` VSCode setting
+* `NEW` `VSCode` help semantic color with market theme
+* `CHG` create/delete/rename files no longer reload workspace (only if client supports file operation protocol)
+* `FIX` `VSCode` settings
* `FIX` [#368](https://github.com/sumneko/lua-language-server/issues/368)
## 1.13.0
`2021-1-28`
-* `NEW` VSCode: status bar
-* `NEW` options in some window
+* `NEW` `VSCode` status bar
+* `NEW` `VSCode` options in some window
* `CHG` performance optimization
* `FIX` endless loop
diff --git a/script/files.lua b/script/files.lua
index 60119b8d..2e0c2666 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -206,6 +206,20 @@ function m.getOriginText(uri)
return file.originText
end
+function m.getChildFiles(uri)
+ uri = getUriKey(uri)
+ local results = {}
+ local uris = m.getAllUris()
+ for _, curi in ipairs(uris) do
+ if #curi > #uri
+ and curi:sub(1, #uri) == uri
+ and curi:sub(#uri+1, #uri+1):match '[/\\]' then
+ results[#results+1] = curi
+ end
+ end
+ return results
+end
+
--- 移除文件
---@param uri uri
function m.remove(uri)
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 2fcc4f70..550b7945 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -197,6 +197,10 @@ proto.on('workspace/didDeleteFiles', function (params)
log.debug('workspace/didDeleteFiles', util.dump(params))
for _, file in ipairs(params.files) do
files.remove(file.uri)
+ local childs = files.getChildFiles(file.uri)
+ for _, uri in ipairs(childs) do
+ files.remove(uri)
+ end
end
end)
@@ -205,8 +209,21 @@ proto.on('workspace/didRenameFiles', function (params)
plugin.awaitReady()
for _, file in ipairs(params.files) do
local text = files.getOriginText(file.oldUri)
- files.remove(file.oldUri)
- files.setText(file.newUri, text, false)
+ if text then
+ files.remove(file.oldUri)
+ files.setText(file.newUri, text, false)
+ end
+ local childs = files.getChildFiles(file.oldUri)
+ for _, uri in ipairs(childs) do
+ local ctext = files.getOriginText(uri)
+ if ctext then
+ local ouri = files.getOriginUri(uri)
+ local tail = ouri:sub(#file.oldUri)
+ local nuri = file.newUri .. tail
+ files.remove(uri)
+ files.setText(nuri, text, false)
+ end
+ end
end
end)