mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(lsp): allow Lua pattern chars in code action filter (#24041)
Previously, filtering code actions with the "only" option failed if the code action kind contained special Lua pattern chars such as "-" (e.g. the ocaml language server supports a "type-annotate" code action). Solution: use string comparison instead of string.find
This commit is contained in:
committed by
GitHub
parent
4e63104c47
commit
c07dceba33
@@ -3357,22 +3357,22 @@ describe('LSP', function()
|
||||
vim.lsp.commands['executed_preferred'] = function()
|
||||
end
|
||||
end
|
||||
vim.lsp.commands['quickfix_command'] = function(cmd)
|
||||
vim.lsp.commands['executed_quickfix'] = function()
|
||||
vim.lsp.commands['type_annotate_command'] = function(cmd)
|
||||
vim.lsp.commands['executed_type_annotate'] = function()
|
||||
end
|
||||
end
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID)
|
||||
vim.lsp.buf.code_action({ filter = function(a) return a.isPreferred end, apply = true, })
|
||||
vim.lsp.buf.code_action({
|
||||
-- expect to be returned actions 'quickfix' and 'quickfix.foo'
|
||||
context = { only = {'quickfix'}, },
|
||||
-- expect to be returned actions 'type-annotate' and 'type-annotate.foo'
|
||||
context = { only = { 'type-annotate' }, },
|
||||
apply = true,
|
||||
filter = function(a)
|
||||
if a.kind == 'quickfix.foo' then
|
||||
vim.lsp.commands['filtered_quickfix_foo'] = function() end
|
||||
if a.kind == 'type-annotate.foo' then
|
||||
vim.lsp.commands['filtered_type_annotate_foo'] = function() end
|
||||
return false
|
||||
elseif a.kind == 'quickfix' then
|
||||
elseif a.kind == 'type-annotate' then
|
||||
return true
|
||||
else
|
||||
assert(nil, 'unreachable')
|
||||
@@ -3382,8 +3382,8 @@ describe('LSP', function()
|
||||
]])
|
||||
elseif ctx.method == 'shutdown' then
|
||||
eq('function', exec_lua[[return type(vim.lsp.commands['executed_preferred'])]])
|
||||
eq('function', exec_lua[[return type(vim.lsp.commands['filtered_quickfix_foo'])]])
|
||||
eq('function', exec_lua[[return type(vim.lsp.commands['executed_quickfix'])]])
|
||||
eq('function', exec_lua[[return type(vim.lsp.commands['filtered_type_annotate_foo'])]])
|
||||
eq('function', exec_lua[[return type(vim.lsp.commands['executed_type_annotate'])]])
|
||||
client.stop()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user