diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 53d8c15d48d92acfc77b8522bf79276116060ff1..2fe72987bc7ce21dbecbd3f7ec77be8355f18163 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -889,6 +889,8 @@ void UnwrappedLineParser::parseStructuralElement() {
       }
       if (Style.Language == FormatStyle::LK_Proto) {
         nextToken();
+        if (FormatTok->is(tok::kw_public))
+          nextToken();
         if (!FormatTok->is(tok::string_literal))
           return;
         nextToken();
diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp
index 68d724981ced14a4135afe0de33526626b6f1877..2580f7fb8c0387f3a31603d13e6e4d465a556591 100644
--- a/unittests/Format/FormatTestProto.cpp
+++ b/unittests/Format/FormatTestProto.cpp
@@ -196,6 +196,12 @@ TEST_F(FormatTestProto, FormatsImports) {
                "message A {\n"
                "}");
 
+  verifyFormat("import public \"a.proto\";\n"
+               "import \"b.proto\";\n"
+               "// comment\n"
+               "message A {\n"
+               "}");
+
   // Missing semicolons should not confuse clang-format.
   verifyFormat("import \"a.proto\"\n"
                "import \"b.proto\"\n"