summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorTomáš Janoušek <tomi@nomi.cz>2021-10-07 04:29:00 +0200
committerGitHub <noreply@github.com>2021-10-07 11:29:00 +0900
commitefa563826d3dd20c4dbd5cbb6b2bdf2f46ac286e (patch)
treee7f4a983ace5ffeecf4b4ea18039727e1ca231f5 /autoload
parentf9deee0e416f626d8597e3e6ea8e89172e5aaa78 (diff)
downloadale-efa563826d3dd20c4dbd5cbb6b2bdf2f46ac286e.zip
codefix: Fix code actions that return Command[] directly instead of CodeAction[] (#3929)
According to https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_codeAction, the response to textDocument/codeAction is: (Command | CodeAction)[] | null and the code only handled the case where it was a CodeAction that either specified an edit or a command, but didn't handle a direct Command. Note that the specification also says that both can be specified and then the edit is applied first, then the command. Furthermore, there seems to be some hacky code handling arguments directly, which I suspect is non-standard and only works with a specific LSP server that happens to pass the edits in the arguments unmodified.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/codefix.vim8
1 files changed, 8 insertions, 0 deletions
diff --git a/autoload/ale/codefix.vim b/autoload/ale/codefix.vim
index 09ee34cb..853ee4e8 100644
--- a/autoload/ale/codefix.vim
+++ b/autoload/ale/codefix.vim
@@ -202,6 +202,14 @@ function! ale#codefix#ApplyLSPCodeAction(data, item) abort
\)
let l:request_id = ale#lsp#Send(a:data.connection_id, l:message)
+ elseif has_key(a:item, 'command') && has_key(a:item, 'arguments')
+ \&& type(a:item.command) == v:t_string
+ let l:message = ale#lsp#message#ExecuteCommand(
+ \ a:item.command,
+ \ a:item.arguments,
+ \)
+
+ let l:request_id = ale#lsp#Send(a:data.connection_id, l:message)
elseif has_key(a:item, 'edit') || has_key(a:item, 'arguments')
if has_key(a:item, 'edit')
let l:topass = a:item.edit