diff options
Diffstat (limited to 'script/client.lua')
-rw-r--r-- | script/client.lua | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/script/client.lua b/script/client.lua index 8ab3ac0e..14320edf 100644 --- a/script/client.lua +++ b/script/client.lua @@ -391,13 +391,41 @@ function m.editText(uri, edits) for i, edit in ipairs(edits) do textEdits[i] = converter.textEdit(converter.packRange(state, edit.start, edit.finish), edit.text) end - proto.request('workspace/applyEdit', { + local params = { edit = { changes = { [uri] = textEdits, } } - }) + } + proto.request('workspace/applyEdit', params) + log.info('workspace/applyEdit', inspect(params)) +end + +---@alias textMultiEditor {uri: uri, start: integer, finish: integer, text: string} + +---@param editors textMultiEditor[] +function m.editMultiText(editors) + local files = require 'files' + local changes = {} + for _, editor in ipairs(editors) do + local uri = editor.uri + local state = files.getState(uri) + if state then + if not changes[uri] then + changes[uri] = {} + end + local edit = converter.textEdit(converter.packRange(state, editor.start, editor.finish), editor.text) + table.insert(changes[uri], edit) + end + end + local params = { + edit = { + changes = changes, + } + } + proto.request('workspace/applyEdit', params) + log.info('workspace/applyEdit', inspect(params)) end ---@param callback async fun(ev: string) |