summaryrefslogtreecommitdiff
path: root/server/src/method
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-04-10 23:18:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-04-10 23:18:29 +0800
commitfe30397aa8478a4e90c5c5caf43a164821905bb6 (patch)
treecf4b90c498b41b874a035e3216883da232f16225 /server/src/method
parent901c464d435d93cdcbfc8833f8f724642920cc7f (diff)
downloadlua-language-server-fe30397aa8478a4e90c5c5caf43a164821905bb6.zip
修正rename的bug
Diffstat (limited to 'server/src/method')
-rw-r--r--server/src/method/textDocument/rename.lua22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/src/method/textDocument/rename.lua b/server/src/method/textDocument/rename.lua
index 95ee0cfe..58013ae0 100644
--- a/server/src/method/textDocument/rename.lua
+++ b/server/src/method/textDocument/rename.lua
@@ -13,12 +13,19 @@ return function (lsp, params)
return {}
end
- local TextEdit = {}
- for i, position in ipairs(positions) do
- local start, finish = position[1], position[2]
+ local changes = {}
+ for _, position in ipairs(positions) do
+ local start, finish, uri = position[1], position[2], position[3]
+ local _, lines = lsp:getVM(uri)
+ if not lines then
+ goto CONTINUE
+ end
local start_row, start_col = lines:rowcol(start)
local finish_row, finish_col = lines:rowcol(finish)
- TextEdit[i] = {
+ if not changes[uri] then
+ changes[uri] = {}
+ end
+ changes[uri][#changes[uri]+1] = {
newText = newName,
range = {
start = {
@@ -32,13 +39,14 @@ return function (lsp, params)
},
}
}
+ ::CONTINUE::
end
local response = {
- changes = {
- [uri] = TextEdit,
- },
+ changes = changes,
}
+ log.debug(table.dump(response))
+
return response
end