1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:04:44 -07:00

internal/lsp: handle err in formatRange

Change-Id: I4aa2715c7adf541da814cb60dd5205dd6e575b61
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184044
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
This commit is contained in:
Rebecca Stambler 2019-06-27 16:29:03 -04:00
parent 19ff4fff88
commit 94c5763a7c

View File

@ -17,12 +17,10 @@ func (s *Server) formatting(ctx context.Context, params *protocol.DocumentFormat
uri := span.NewURI(params.TextDocument.URI)
view := s.session.ViewOf(uri)
spn := span.New(uri, span.Point{}, span.Point{})
return formatRange(ctx, view, spn)
}
// formatRange formats a document with a given range.
func formatRange(ctx context.Context, view source.View, s span.Span) ([]protocol.TextEdit, error) {
f, m, rng, err := spanToRange(ctx, view, s)
f, m, rng, err := spanToRange(ctx, view, spn)
if err != nil {
return nil, err
}
edits, err := source.Format(ctx, f, rng)
if err != nil {
return nil, err