Skip to content

Commit a2d70d8

Browse files
committed
fix(codactions): fix action resolution
1 parent 0fcbd7f commit a2d70d8

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

lua/cosmic-ui/code-action/init.lua

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,26 @@ M.code_actions = function(opts)
142142
local action = item.ctx.command
143143
local client = item.ctx.client
144144

145-
client.request('codeAction/resolve', action, function(resolved_err, resolved_action)
146-
if resolved_err then
147-
vim.notify(resolved_err.code .. ': ' .. resolved_err.message, vim.log.levels.ERROR)
148-
return
149-
end
150-
if resolved_action then
151-
execute_action(transform_action(resolved_action))
152-
else
153-
execute_action(transform_action(action))
154-
end
155-
end)
145+
if
146+
not action.edit
147+
and client
148+
and type(client.resolved_capabilities.code_action) == 'table'
149+
and client.resolved_capabilities.code_action.resolveProvider
150+
then
151+
client.request('codeAction/resolve', action, function(resolved_err, resolved_action)
152+
if resolved_err then
153+
vim.notify(resolved_err.code .. ': ' .. resolved_err.message, vim.log.levels.ERROR)
154+
return
155+
end
156+
if resolved_action then
157+
execute_action(transform_action(resolved_action))
158+
else
159+
execute_action(transform_action(action))
160+
end
161+
end)
162+
else
163+
execute_action(transform_action(action))
164+
end
156165
end,
157166
})
158167

0 commit comments

Comments
 (0)