Skip to content

Commit

Permalink
exit early so as to not format without request
Browse files Browse the repository at this point in the history
  • Loading branch information
jpogran committed Oct 18, 2021
1 parent bd380a5 commit 10eabe1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/langserver/handlers/code_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ func (h *logHandler) TextDocumentCodeAction(ctx context.Context, params lsp.Code
func (h *logHandler) textDocumentCodeAction(ctx context.Context, params lsp.CodeActionParams) ([]lsp.CodeAction, error) {
var ca []lsp.CodeAction

// we only support format type code actions at the moment, and do not want to
// format ranges or documents without the client asking for them, so exit early
// here if nothing is requested.
if len(params.Context.Only) == 0 {
return ca, nil
}

wantedCodeActions := ilsp.SupportedCodeActions.Only(params.Context.Only)
if len(wantedCodeActions) == 0 {
return nil, fmt.Errorf("could not find a supported code action to execute for %s, wanted %v",
Expand Down

0 comments on commit 10eabe1

Please sign in to comment.