diff options
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/core/rename.lua | 21 | ||||
-rw-r--r-- | server-beta/src/workspace/workspace.lua | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/server-beta/src/core/rename.lua b/server-beta/src/core/rename.lua index fc600d6e..e457a803 100644 --- a/server-beta/src/core/rename.lua +++ b/server-beta/src/core/rename.lua @@ -3,6 +3,7 @@ local searcher = require 'searcher' local guide = require 'parser.guide' local proto = require 'proto' local define = require 'proto.define' +local ws = require 'workspace' local Forcing @@ -48,7 +49,7 @@ local function askForcing(str) end end -local function askForMultiChange(results) +local function askForMultiChange(results, newname) if TEST then return true end @@ -65,19 +66,13 @@ local function askForMultiChange(results) 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( + message = ('将修改 %d 个文件,共 %d 处。'):format( #uris, - #results, - table.concat(fileList, '\r\n') + #results ), actions = { { @@ -96,6 +91,12 @@ local function askForMultiChange(results) return false end if item and item.title == '继续' then + local fileList = {} + for _, uri in ipairs(uris) do + fileList[#fileList+1] = ('%s (%d)'):format(uri, uris[uri]) + end + + log.debug(('Renamed [%s]\r\n%s'):format(newname, table.concat(fileList, '\r\n'))) return true end return false @@ -323,7 +324,7 @@ function m.rename(uri, pos, newname) return nil end - if not askForMultiChange(results) then + if not askForMultiChange(results, newname) then return nil end diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua index d5e6310e..37ec2d7b 100644 --- a/server-beta/src/workspace/workspace.lua +++ b/server-beta/src/workspace/workspace.lua @@ -186,4 +186,9 @@ function m.findUrisByRequirePath(path, whole) return results end +function m.getRelativePath(uri) + local path = furi.decode(uri) + return fs.relative(fs.path(path), fs.path(m.path)):string() +end + return m |