From 2cb7e11cc151c42e2981b2a460bbbe4ded5be5ee Mon Sep 17 00:00:00 2001 From: Richard Mathieson <35163478+rlch@users.noreply.github.com> Date: Tue, 18 Jan 2022 18:07:29 +1100 Subject: [PATCH] fix: add offset encoding to `apply_workspace_edit` call (#1697) --- lua/telescope/builtin/lsp.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua index c2d1b76..737cad1 100644 --- a/lua/telescope/builtin/lsp.lua +++ b/lua/telescope/builtin/lsp.lua @@ -266,10 +266,10 @@ lsp.code_actions = function(opts) end local execute_action = opts.execute_action - or function(action) + or function(action, offset_encoding) if action.edit or type(action.command) == "table" then if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit) + vim.lsp.util.apply_workspace_edit(action.edit, offset_encoding) end if type(action.command) == "table" then vim.lsp.buf.execute_command(action.command) @@ -297,6 +297,9 @@ lsp.code_actions = function(opts) actions.close(prompt_bufnr) local action = selection.value.command local client = selection.value.client + local eff_execute = function(transformed) + execute_action(transformed, client.offset_encoding) + end if not action.edit and client @@ -309,13 +312,13 @@ lsp.code_actions = function(opts) return end if resolved_action then - execute_action(transform_action(resolved_action)) + eff_execute(transform_action(resolved_action)) else - execute_action(transform_action(action)) + eff_execute(transform_action(action)) end end) else - execute_action(transform_action(action)) + eff_execute(transform_action(action)) end end)