Skip to content

When formatting protobuf, clang-format inserts a space after "keyword" inside field options #54848

@hexchain

Description

@hexchain

Protobuf keywords may appear in a field option, e.g. https://github.com/envoyproxy/protoc-gen-validate/blob/main/README.md#repeated. When formatting a file with such field option, clang-format insists on inserting a space after the "keyword".

Example file:

syntax = "proto3";
package proto.test;

message A {
  int32 a = 1;
}

message B {
  repeated A a = 1 [(annotation).int32.repeated.required.optional.oneof.test = true];
}

Output of clang-format --style=Google:

syntax = "proto3";
package proto.test;

message A {
  int32 a = 1;
}

message B {
  repeated A a = 1
      [(annotation).int32.repeated .required .optional .oneof.test = true];
}

Expected output:

No space should be inserted after "keywords" in a field option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorclang-format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions