Skip to content

Commit

Permalink
internal/lsp: fix TestCompatibleCodeActions
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Apr 6, 2024
1 parent c4eff1c commit 57f8560
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lsp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func CompatibleCodeActions(cap *protocol.ServerCapabilities, kinds []protocol.Co
log.Printf("CompatibleCodeActions: unexpected CodeActionProvider type %T", ap)
case bool:
if ap {
allowed = kinds
return kinds
}
return nil
case protocol.CodeActionOptions:
Expand Down
13 changes: 13 additions & 0 deletions internal/lsp/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ func TestCompatibleCodeActions(t *testing.T) {
[]protocol.CodeActionKind{protocol.SourceOrganizeImports},
[]protocol.CodeActionKind{protocol.SourceOrganizeImports},
},
{
"OneFoundMap",
protocol.ServerCapabilities{
CodeActionProvider: map[string]any{
"codeActionKinds": []any{
"quickfix",
"source.organizeImports",
},
},
},
[]protocol.CodeActionKind{protocol.SourceOrganizeImports},
[]protocol.CodeActionKind{protocol.SourceOrganizeImports},
},
} {
t.Run(tc.name, func(t *testing.T) {
got := CompatibleCodeActions(&tc.cap, tc.kinds)
Expand Down

0 comments on commit 57f8560

Please sign in to comment.