autoload/lsp/codeaction.vim | 9 +++++++-- diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 63d1cae72a50f8e18e60db7b15d4af8deb441e41..02bf7cd8ce7e6433b73f4f39fa9fd9f030ccbe3d 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -10,15 +10,20 @@ export def HandleCodeAction(lspserver: dict, selAction: dict) # textDocument/codeAction can return either Command[] or CodeAction[]. # If it is a CodeAction, it can have either an edit, a command or both. # Edits should be executed first. - if selAction->has_key('edit') || selAction->has_key('command') + # Both Command and CodeAction interfaces has 'command' member + # so we should check 'command' type - for Command it will be 'string' + if selAction->has_key('edit') + || (selAction->has_key('command') && selAction.command->type() == v:t_dict) + # selAction is a CodeAction instance, apply edit and command if selAction->has_key('edit') # apply edit first textedit.ApplyWorkspaceEdit(selAction.edit) endif if selAction->has_key('command') - lspserver.executeCommand(selAction) + lspserver.executeCommand(selAction.command) endif else + # selAction is a Command instance, apply it directly lspserver.executeCommand(selAction) endif enddef