diff options
author | Chris Kipp <ckipp@pm.me> | 2021-09-24 03:20:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 18:20:10 -0700 |
commit | 433bda405e1fa82db23660a73f275cac5ecca95e (patch) | |
tree | 097969ae73ce195e8c835fdc74c92ab45584856f /src/nvim/quickfix.c | |
parent | be938216474e8adac62199fabb94c5417b17db32 (diff) | |
download | rneovim-433bda405e1fa82db23660a73f275cac5ecca95e.tar.gz rneovim-433bda405e1fa82db23660a73f275cac5ecca95e.tar.bz2 rneovim-433bda405e1fa82db23660a73f275cac5ecca95e.zip |
fix(lsp): guard textDocument/codeAction command logic #15769
Problem:
Error executing vim.schedule lua callback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: command: expected string, got
nil
stack traceback:
...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: in function 'execute_command'
...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:151: in function <...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:113>
...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:465: in function 'callback'
...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:1325: in function 'handler'
...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:899: in function 'cb'
vim.lua:281: in function <vim.lua:281>
Solution:
This is a follow-up to the work done in
https://github.com/neovim/neovim/commit/6c03601e3adb4c3c4d47f148df8df20401b88677.
There are valid situations where a `textDocument/codeAction` is returned
without a command, since a command in optional. For example from Metals,
the Scala language server when you get a code action to add a missing
import, it looks like this:
```json
Result: [
{
"title": "Import \u0027Instant\u0027 from package \u0027java.time\u0027",
"kind": "quickfix",
"diagnostics": [
{
"range": {
"start": {
"line": 6,
"character": 10
},
"end": {
"line": 6,
"character": 17
}
},
"severity": 1,
"source": "bloop",
"message": "not found: value Instant"
}
],
"edit": {
"changes": {
"file:///Users/ckipp/Documents/scala-workspace/sanity/src/main/scala/Thing.scala": [
{
"range": {
"start": {
"line": 6,
"character": 10
},
"end": {
"line": 6,
"character": 17
}
},
"newText": "Instant"
},
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"newText": "\nimport java.time.Instant\n"
}
]
}
}
}
]
```
This change just wraps the logic that grabs the command in a conditional
to skip it if there is no command.
Diffstat (limited to 'src/nvim/quickfix.c')
0 files changed, 0 insertions, 0 deletions