@@ -845,6 +845,35 @@ void testRunMultiline() {
845845 assertLiteral (args .get (7 ), Quoting .UNQUOTED , " " , "gcc" , "" );
846846 }
847847
848+ @ Test
849+ void testRunMultilineClearsContinuation () {
850+ DockerfileParser parser = new DockerfileParser ();
851+ Docker .Document doc = parser .parse (new ByteArrayInputStream (
852+ """
853+ RUN echo Hello \\
854+ World
855+ # This is a comment
856+ # This is another comment
857+ """ .getBytes (StandardCharsets .UTF_8 )));
858+
859+ Docker .Stage stage = assertSingleStageWithChildCount (doc , 3 );
860+
861+ Docker .Run cmd = (Docker .Run ) stage .getChildren ().get (0 );
862+ assertEquals (Space .EMPTY , cmd .getPrefix ());
863+
864+ List <Docker .Literal > args = cmd .getCommands ();
865+ assertEquals (3 , args .size ());
866+
867+ assertLiteral (args .get (0 ), Quoting .UNQUOTED , " " , "echo" , "" );
868+ assertLiteral (args .get (1 ), Quoting .UNQUOTED , " " , "Hello" , " \\ \n " );
869+ assertLiteral (args .get (2 ), Quoting .UNQUOTED , " " , "World" , "" );
870+
871+ Docker .Comment comment1 = (Docker .Comment ) stage .getChildren ().get (1 );
872+ assertLiteral (comment1 .getText (), Quoting .UNQUOTED , " " , "This is a comment" , "" );
873+ Docker .Comment comment2 = (Docker .Comment ) stage .getChildren ().get (2 );
874+ assertLiteral (comment2 .getText (), Quoting .UNQUOTED , " " , "This is another comment" , "" );
875+ }
876+
848877 /**
849878 * Test this example heredoc from the Dockerfile reference:
850879 * RUN <<EOF
0 commit comments