go-language-server / protocol

Package protocol implements Language Server Protocol specification in Go
https://pkg.go.dev/go.lsp.dev/protocol
BSD 3-Clause "New" or "Revised" License
97 stars 15 forks source link

fix: it must be possible to have a nil range to replace all content in the TextDocumentChangeEvent #41

Closed a-h closed 1 year ago

a-h commented 1 year ago

If the range field is null, then it means that the text should overwrite the whole document:

{"text":"replace all"}

If the range start and end is the same value, then it means to insert the text at that point:

{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"rangeLength":3,"text":"insert at 0,0"}

In the current version, range is not a pointer, so the range start and end fields gets default Go zero values of {"line":0,"character":0}. Setting omitempty on the range field doesn't make any difference, unless the range field becomes a pointer.

So, this change converts range to be a pointer, to be able to express the idea that a range can be omitted from the message.