add offset_encoding to code_action apply_workspace_edit (#314)

main
bhagwan 2 years ago
parent 1546c82b67
commit 7e7f6d8cc3

@ -386,10 +386,10 @@ M.code_actions = function(opts)
end end
local execute_action = opts.execute_action local execute_action = opts.execute_action
or function(action) or function(action, enc)
if action.edit or type(action.command) == "table" then if action.edit or type(action.command) == "table" then
if action.edit then if action.edit then
vim.lsp.util.apply_workspace_edit(action.edit) vim.lsp.util.apply_workspace_edit(action.edit, enc)
end end
if type(action.command) == "table" then if type(action.command) == "table" then
vim.lsp.buf.execute_command(action.command) vim.lsp.buf.execute_command(action.command)
@ -406,6 +406,7 @@ M.code_actions = function(opts)
local entry = opts.code_actions[idx] local entry = opts.code_actions[idx]
local action = entry.command local action = entry.command
local client = entry.client or vim.lsp.get_client_by_id(entry.client_id) local client = entry.client or vim.lsp.get_client_by_id(entry.client_id)
local offset_encoding = client and client.offset_encoding
if if
not action.edit not action.edit
and client and client
@ -420,13 +421,13 @@ M.code_actions = function(opts)
return return
end end
if resolved_action then if resolved_action then
execute_action(transform_action(resolved_action)) execute_action(transform_action(resolved_action), offset_encoding)
else else
execute_action(transform_action(action)) execute_action(transform_action(action), offset_encoding)
end end
end) end)
else else
execute_action(transform_action(action)) execute_action(transform_action(action), offset_encoding)
end end
end) end)

Loading…
Cancel
Save