@@ -201,6 +201,32 @@ The door of all subtleties!
201201 )
202202 testPrint (t , lao , tzu , edits , "lao-tzu" )
203203 })
204+
205+ t .Run ("first-line-prefix" , func (t * testing.T ) {
206+ t .Parallel ()
207+ from := "syntax = \" proto3\" ;\n \n package test;\n \n message Foo {\n string field1 = 1;\n string field2 = 2;\n string field3 = 3;\n string field4 = 4;\n string field5 = 5;\n }\n "
208+ to := "syntax = \" proto3\" ;\n \n package test;\n \n message Foo {\n string field1 = 1;\n string field2 = 2;\n string field3 = 3;\n string field4 = 4;\n int32 field5 = 5;\n }\n "
209+ expectedFirstLineOfOutput := " syntax = \" proto3\" ;"
210+ fromLines := splitLines (from )
211+ toLines := splitLines (to )
212+ edits := diffmyers .Diff (
213+ fromLines ,
214+ toLines ,
215+ )
216+ diff , err := diffmyers .Print (
217+ fromLines ,
218+ toLines ,
219+ edits ,
220+ )
221+ require .NoError (t , err )
222+ firstLineEnd := bytes .Index (diff , []byte ("\n " ))
223+
224+ firstLine := diff [:firstLineEnd ]
225+ actualFirstLine := string (firstLine )
226+ require .Equal (t , expectedFirstLineOfOutput , actualFirstLine ,
227+ "First line of diff output should match expected format (single space prefix, no double space)" )
228+ testPrint (t , from , to , edits , "first-line-prefix" )
229+ })
204230}
205231
206232func testPrint (t * testing.T , from , to string , edits []diffmyers.Edit , golden string ) {
0 commit comments