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:
parent
5cec639030
commit
9cb3dcf692
1
internal/lsp/testdata/format/one_line.go.in
vendored
Normal file
1
internal/lsp/testdata/format/one_line.go.in
vendored
Normal file
@ -0,0 +1 @@
|
||||
package format //@format("package")
|
6
internal/lsp/testdata/format/one_line.gofmt-d.golden.go
vendored
Normal file
6
internal/lsp/testdata/format/one_line.gofmt-d.golden.go
vendored
Normal 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")
|
1
internal/lsp/testdata/format/one_line.gofmt.golden.go
vendored
Normal file
1
internal/lsp/testdata/format/one_line.gofmt.golden.go
vendored
Normal file
@ -0,0 +1 @@
|
||||
package format //@format("package")
|
@ -29,7 +29,7 @@ import (
|
||||
const (
|
||||
ExpectedCompletionsCount = 85
|
||||
ExpectedDiagnosticsCount = 17
|
||||
ExpectedFormatCount = 4
|
||||
ExpectedFormatCount = 5
|
||||
ExpectedDefinitionsCount = 21
|
||||
ExpectedTypeDefinitionsCount = 2
|
||||
ExpectedHighlightsCount = 2
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user