1
0
mirror of https://github.com/golang/go synced 2024-11-18 08:54:45 -07:00

internal/span: update the offset if the end offset should be valid but is not

It used to be that when the start offset was valid, it was presumed the end was
as well.
This was not true in the case where the start offset was not supplied but could
be inferred (at the very start of the file).

Fixes golang/go#31797

Change-Id: Ie5a079796fa0f77cef5571a4e5b309c798e1e06b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174943
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Ian Cottrell 2019-05-02 13:01:46 -04:00
parent 5cec639030
commit 9cb3dcf692
5 changed files with 10 additions and 2 deletions

View File

@ -0,0 +1 @@
package format //@format("package")

View File

@ -0,0 +1,6 @@
--- format/one_line.go.orig
+++ format/one_line.go
@@ -1 +1 @@
-package format //@format("package")
\ No newline at end of file
+package format //@format("package")

View File

@ -0,0 +1 @@
package format //@format("package")

View File

@ -29,7 +29,7 @@ import (
const (
ExpectedCompletionsCount = 85
ExpectedDiagnosticsCount = 17
ExpectedFormatCount = 4
ExpectedFormatCount = 5
ExpectedDefinitionsCount = 21
ExpectedTypeDefinitionsCount = 2
ExpectedHighlightsCount = 2

View File

@ -249,7 +249,7 @@ func (s *Span) update(c Converter, withPos, withOffset bool) error {
return err
}
}
if withOffset && !s.HasOffset() {
if withOffset && (!s.HasOffset() || (s.v.End.hasPosition() && !s.v.End.hasOffset())) {
if err := s.v.Start.updateOffset(c); err != nil {
return err
}