mirror of https://github.com/golang/go.git
internal/lsp: don't panic if there are no suggested fixes
If an analyzer doesn't return error, and doesn't have any suggested fixs either gopls panics. Return an empty set of edits instead. Change-Id: I1cd812fedcbd2ddc01229f48c0cc4467ee3f0105 Reviewed-on: https://go-review.googlesource.com/c/tools/+/249998 Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
307de81be3
commit
c024452afb
|
|
@ -171,6 +171,10 @@ func (c *Command) SuggestedFix(ctx context.Context, snapshot Snapshot, fh Versio
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fix == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var edits []protocol.TextDocumentEdit
|
||||
for _, edit := range fix.TextEdits {
|
||||
rng := span.NewRange(fset, edit.Pos, edit.End)
|
||||
|
|
|
|||
Loading…
Reference in New Issue