mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-19 01:22:57 +08:00
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.
This commit is contained in:
@@ -201,6 +201,14 @@ function! ale#codefix#ApplyLSPCodeAction(data, item) abort
|
||||
\ l:command.arguments,
|
||||
\)
|
||||
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user