Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1124,8 +1124,11 @@ if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 && CurrentToken->is(Keywords.kw_option)) { next(); - if (CurrentToken && CurrentToken->is(tok::identifier)) + if (CurrentToken && CurrentToken->is(tok::identifier)) { + while (CurrentToken) + next(); return LT_ImportStatement; + } } bool KeywordVirtualFound = false; Index: unittests/Format/FormatTestProto.cpp =================================================================== --- unittests/Format/FormatTestProto.cpp +++ unittests/Format/FormatTestProto.cpp @@ -193,6 +193,10 @@ "\"some.really.long.package.that.exceeds.the.column.limit\";")); } +TEST_F(FormatTestProto, TrailingCommentAfterFileOption) { + verifyFormat("option java_package = \"foo.pkg\"; // comment\n"); +} + TEST_F(FormatTestProto, FormatsOptions) { verifyFormat("option (MyProto.options) = {\n" " field_a: OK\n"