mirror of https://github.com/golang/go.git
internal/lsp: make Text in DidSave request a pointer
Fixes golang/go#36063 Change-Id: I223ead138111239ae1894f5565414ac384c016e2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/210780 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com>
This commit is contained in:
parent
22774f7dae
commit
0bd90eac95
|
|
@ -101,6 +101,19 @@ func TestCapabilities(t *testing.T) {
|
|||
t.Errorf("unexpected command for import organization")
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.Server.DidSave(ctx, &protocol.DidSaveTextDocumentParams{
|
||||
TextDocument: protocol.VersionedTextDocumentIdentifier{
|
||||
Version: 2,
|
||||
TextDocumentIdentifier: protocol.TextDocumentIdentifier{
|
||||
URI: uri,
|
||||
},
|
||||
},
|
||||
// LSP specifies that a file can be saved with optional text, so this field must be nil.
|
||||
Text: nil,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func validateCapabilities(result *protocol.InitializeResult) error {
|
||||
|
|
|
|||
|
|
@ -1027,7 +1027,7 @@ type DidSaveTextDocumentParams struct {
|
|||
* Optional the content when saved. Depends on the includeText value
|
||||
* when the save notification was requested.
|
||||
*/
|
||||
Text string `json:"text,omitempty"`
|
||||
Text *string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
type DocumentColorClientCapabilities struct {
|
||||
|
|
|
|||
|
|
@ -30,12 +30,15 @@ func (s *Server) didOpen(ctx context.Context, params *protocol.DidOpenTextDocume
|
|||
}
|
||||
|
||||
func (s *Server) didSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) error {
|
||||
return s.didModifyFile(ctx, source.FileModification{
|
||||
c := source.FileModification{
|
||||
URI: span.NewURI(params.TextDocument.URI),
|
||||
Action: source.Save,
|
||||
Version: params.TextDocument.Version,
|
||||
Text: []byte(params.Text),
|
||||
})
|
||||
}
|
||||
if params.Text != nil {
|
||||
c.Text = []byte(*params.Text)
|
||||
}
|
||||
return s.didModifyFile(ctx, c)
|
||||
}
|
||||
|
||||
func (s *Server) didClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue