Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): explicitly mark source_text optional ∵ File.text is optional #5666

Merged
merged 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion kythe/go/serving/xrefs/xrefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (t *Table) Decorations(ctx context.Context, req *xpb.DecorationsRequest) (*
})
}

if req.SourceText {
if req.SourceText && text != nil {
reply.Encoding = decor.File.Encoding
if loc.Kind == xpb.Location_FILE {
reply.SourceText = text
Expand Down
4 changes: 2 additions & 2 deletions kythe/go/serving/xrefs/xrefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func TestDecorationsRefs(t *testing.T) {
})
testutil.Fatalf(t, "DecorationsRequest error: %v", err)

if len(reply.SourceText) != 0 {
if reply.SourceText != nil {
t.Errorf("Unexpected source text: %q", string(reply.SourceText))
}
if reply.Encoding != "" {
Expand Down Expand Up @@ -912,7 +912,7 @@ func TestDecorationsDirtyBuffer(t *testing.T) {
})
testutil.Fatalf(t, "DecorationsRequest error: %v", err)

if len(reply.SourceText) != 0 {
if reply.SourceText != nil {
t.Errorf("Unexpected source text: %q", string(reply.SourceText))
}
if reply.Encoding != "" {
Expand Down
2 changes: 1 addition & 1 deletion kythe/proto/xref.proto
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ message DecorationsReply {
string revision = 18;

// The encoded source text for the selected window.
bytes source_text = 2;
optional bytes source_text = 2;
string encoding = 3;

// Represents a reference edge source ---KIND---> target. Each source is an
Expand Down