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:
Jonas Strittmatter
2023-06-17 08:01:31 +02:00
committed by GitHub
parent 4e63104c47
commit c07dceba33
3 changed files with 20 additions and 20 deletions

View File

@@ -608,9 +608,9 @@ local function on_code_action_results(results, ctx, options)
end
local found = false
for _, o in ipairs(options.context.only) do
-- action kinds are hierarchical with . as a separator: when requesting only
-- 'quickfix' this filter allows both 'quickfix' and 'quickfix.foo', for example
if a.kind:find('^' .. o .. '$') or a.kind:find('^' .. o .. '%.') then
-- action kinds are hierarchical with . as a separator: when requesting only 'type-annotate'
-- this filter allows both 'type-annotate' and 'type-annotate.foo', for example
if a.kind == o or vim.startswith(a.kind, o .. '.') then
found = true
break
end