summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/core/rename.lua58
-rw-r--r--server-beta/src/provider/init.lua5
2 files changed, 59 insertions, 4 deletions
diff --git a/server-beta/src/core/rename.lua b/server-beta/src/core/rename.lua
index 0d932a4f..fc600d6e 100644
--- a/server-beta/src/core/rename.lua
+++ b/server-beta/src/core/rename.lua
@@ -48,6 +48,59 @@ local function askForcing(str)
end
end
+local function askForMultiChange(results)
+ if TEST then
+ return true
+ end
+ local uris = {}
+ for _, result in ipairs(results) do
+ local uri = result.uri
+ if not uris[uri] then
+ uris[uri] = 0
+ uris[#uris+1] = uri
+ end
+ uris[uri] = uris[uri] + 1
+ end
+ if #uris <= 1 then
+ return true
+ end
+
+ local fileList = {}
+ for _, uri in ipairs(uris) do
+ fileList[#fileList+1] = ('%s (%d)'):format(uri, uris[uri])
+ end
+
+ local version = files.globalVersion
+ -- TODO
+ local item = proto.awaitRequest('window/showMessageRequest', {
+ type = define.MessageType.Warning,
+ message = ('将修改以下 %d 个文件,共 %d 处。\r\n%s'):format(
+ #uris,
+ #results,
+ table.concat(fileList, '\r\n')
+ ),
+ actions = {
+ {
+ title = '继续',
+ },
+ {
+ title = '放弃',
+ },
+ }
+ })
+ if version ~= files.globalVersion then
+ proto.notify('window/showMessage', {
+ type = define.MessageType.Warning,
+ message = '文件发生了变化,替换取消。'
+ })
+ return false
+ end
+ if item and item.title == '继续' then
+ return true
+ end
+ return false
+end
+
local function isValidName(str)
return str:match '^[%a_][%w_]*$'
end
@@ -269,6 +322,11 @@ function m.rename(uri, pos, newname)
if #results == 0 then
return nil
end
+
+ if not askForMultiChange(results) then
+ return nil
+ end
+
return results
end
diff --git a/server-beta/src/provider/init.lua b/server-beta/src/provider/init.lua
index 41a1aed5..41a022da 100644
--- a/server-beta/src/provider/init.lua
+++ b/server-beta/src/provider/init.lua
@@ -43,9 +43,6 @@ local function updateConfig()
end
if not util.equal(oldConfig.diagnostics, newConfig.diagnostics) then
end
- if newConfig.completion.enable then
- else
- end
if not util.equal(oldConfig.plugin, newConfig.plugin) then
end
if not util.equal(oldConfig.workspace, newConfig.workspace)
@@ -56,7 +53,7 @@ local function updateConfig()
end
if newConfig.completion.enable then
- completion.enable()
+ --completion.enable()
else
completion.disable()
end