Skip to content

Commit d518495

Browse files
committed
internal/lsp: log errors for compute fix edits instead of returning
Fixes #40260 Change-Id: I69032b8cd6b32a262ecd3bb746ef6d1722966a51 Reviewed-on: https://go-review.googlesource.com/c/tools/+/243238 Run-TryBot: Rebecca Stambler <[email protected]> Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 58eba7e commit d518495

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

internal/lsp/code_action.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
8282
if wantQuickFixes := wanted[protocol.QuickFix] && len(diagnostics) > 0; wantQuickFixes || wanted[protocol.SourceOrganizeImports] {
8383
importEdits, importEditsPerFix, err := source.AllImportsFixes(ctx, snapshot, fh)
8484
if err != nil {
85-
return nil, err
85+
event.Error(ctx, "imports fixes", err, tag.File.Of(fh.URI().Filename()))
8686
}
8787
// Separate this into a set of codeActions per diagnostic, where
8888
// each action is the addition, removal, or renaming of one import.

internal/lsp/source/format.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package source
88
import (
99
"bytes"
1010
"context"
11+
"fmt"
1112
"go/ast"
1213
"go/format"
1314
"go/parser"
@@ -18,7 +19,6 @@ import (
1819
"golang.org/x/tools/internal/imports"
1920
"golang.org/x/tools/internal/lsp/diff"
2021
"golang.org/x/tools/internal/lsp/protocol"
21-
errors "golang.org/x/xerrors"
2222
)
2323

2424
// Format formats a file with a given range.
@@ -95,7 +95,7 @@ func AllImportsFixes(ctx context.Context, snapshot Snapshot, fh FileHandle) (all
9595
allFixEdits, editsPerFix, err = computeImportEdits(ctx, snapshot.View(), pgh, opts)
9696
return err
9797
}); err != nil {
98-
return nil, nil, errors.Errorf("computing fix edits: %v", err)
98+
return nil, nil, fmt.Errorf("AllImportsFixes: %v", err)
9999
}
100100
return allFixEdits, editsPerFix, nil
101101
}

0 commit comments

Comments
 (0)