mirror of https://github.com/golang/go.git
internal/lsp: make Range a pointer in Change events
Change 207598 overenthusiastically (and incorrectly) changed the Range field in a TextDocumentContentChangeEvent from type *Range to type Range, which created a bug in text_synchronization.go. This CL attempts to repair the damage. Change-Id: I19e7418cd5ebaedf5448adfcc60ca86e71eb9b2f Reviewed-on: https://go-review.googlesource.com/c/tools/+/208097 Run-TryBot: Peter Weinberger <pjw@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
0a33398bd9
commit
cefbc64fbd
|
|
@ -2871,7 +2871,7 @@ type TextDocumentContentChangeEvent struct {
|
|||
/**
|
||||
* The range of the document that changed.
|
||||
*/
|
||||
Range Range `json:"range,omitempty"`
|
||||
Range *Range `json:"range,omitempty"`
|
||||
/**
|
||||
* The length of the range that got replaced.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func fullChange(changes []protocol.TextDocumentContentChangeEvent) (string, bool
|
|||
}
|
||||
// The length of the changes must be 1 at this point.
|
||||
// TODO: This breaks if you insert a character at the beginning of the file.
|
||||
if (changes[0].Range == protocol.Range{} && changes[0].RangeLength == 0) {
|
||||
if changes[0].Range == nil && changes[0].RangeLength == 0 {
|
||||
return changes[0].Text, true
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ func (s *Server) applyChanges(ctx context.Context, uri span.URI, changes []proto
|
|||
Content: content,
|
||||
}
|
||||
|
||||
spn, err := m.RangeSpan(change.Range)
|
||||
spn, err := m.RangeSpan(*change.Range) // Could Range be nil here?
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue