diff options
author | Jonas Strittmatter <40792180+smjonas@users.noreply.github.com> | 2023-06-17 08:01:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-17 08:01:31 +0200 |
commit | c07dceba335c56c9a356395ad0d1e5a14d416752 (patch) | |
tree | 9ea6cbcca5d3a0e2986ad17e9685d3681e67800c /test | |
parent | 4e63104c47132adee7d1dc678d69d80e867371bf (diff) | |
download | rneovim-c07dceba335c56c9a356395ad0d1e5a14d416752.tar.gz rneovim-c07dceba335c56c9a356395ad0d1e5a14d416752.tar.bz2 rneovim-c07dceba335c56c9a356395ad0d1e5a14d416752.zip |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 16 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 18 |
2 files changed, 17 insertions, 17 deletions
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index dc0428afdc..ea5e03e0eb 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -831,21 +831,21 @@ function tests.code_action_filter() isPreferred = true, command = 'preferred_command', } - local quickfix_action = { + local type_annotate_action = { title = 'Action 3', - kind = 'quickfix', - command = 'quickfix_command', + kind = 'type-annotate', + command = 'type_annotate_command', } - local quickfix_foo_action = { + local type_annotate_foo_action = { title = 'Action 4', - kind = 'quickfix.foo', - command = 'quickfix_foo_command', + kind = 'type-annotate.foo', + command = 'type_annotate_foo_command', } expect_request('textDocument/codeAction', function() - return nil, { action, preferred_action, quickfix_action, quickfix_foo_action, } + return nil, { action, preferred_action, type_annotate_action, type_annotate_foo_action, } end) expect_request('textDocument/codeAction', function() - return nil, { action, preferred_action, quickfix_action, quickfix_foo_action, } + return nil, { action, preferred_action, type_annotate_action, type_annotate_foo_action, } end) notify('shutdown') end; diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 2f4a703c74..e9993eee2a 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -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 |