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>
diff --git a/internal/lsp/protocol/tsprotocol.go b/internal/lsp/protocol/tsprotocol.go
index 1008a7f..5657378 100644
--- a/internal/lsp/protocol/tsprotocol.go
+++ b/internal/lsp/protocol/tsprotocol.go
@@ -2871,7 +2871,7 @@
/**
* 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.
*/
diff --git a/internal/lsp/text_synchronization.go b/internal/lsp/text_synchronization.go
index 0a31b78..57e8b00 100644
--- a/internal/lsp/text_synchronization.go
+++ b/internal/lsp/text_synchronization.go
@@ -97,7 +97,7 @@
}
// 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 @@
Content: content,
}
- spn, err := m.RangeSpan(change.Range)
+ spn, err := m.RangeSpan(*change.Range) // Could Range be nil here?
if err != nil {
return "", err
}