@@ -382,6 +382,42 @@ func Test_confirm_write_ro()
382382 call delete (' Xconfirm_write_ro' )
383383endfunc
384384
385+ func Test_confirm_write_partial_file ()
386+ CheckNotGui
387+ CheckRunVimInTerminal
388+
389+ call writefile ([' a' , ' b' , ' c' , ' d' ], ' Xwrite_partial' )
390+ call writefile ([' set nobackup ff=unix cmdheight=2' ,
391+ \ ' edit Xwrite_partial' ], ' Xscript' )
392+ let buf = RunVimInTerminal (' -S Xscript' , {' rows' : 20 })
393+
394+ call term_sendkeys (buf , " :confirm 2,3w\n " )
395+ call WaitForAssert ({- > assert_match (' ^Write partial file? *$' ,
396+ \ term_getline (buf , 19 ))}, 1000 )
397+ call WaitForAssert ({- > assert_match (' ^(Y)es, \[N\]o: *$' ,
398+ \ term_getline (buf , 20 ))}, 1000 )
399+ call term_sendkeys (buf , ' N' )
400+ call WaitForAssert ({- > assert_match (' .* All$' , term_getline (buf , 20 ))}, 1000 )
401+ call assert_equal ([' a' , ' b' , ' c' , ' d' ], readfile (' Xwrite_partial' ))
402+ call delete (' Xwrite_partial' )
403+
404+ call term_sendkeys (buf , " :confirm 2,3w\n " )
405+ call WaitForAssert ({- > assert_match (' ^Write partial file? *$' ,
406+ \ term_getline (buf , 19 ))}, 1000 )
407+ call WaitForAssert ({- > assert_match (' ^(Y)es, \[N\]o: *$' ,
408+ \ term_getline (buf , 20 ))}, 1000 )
409+ call term_sendkeys (buf , ' Y' )
410+ call WaitForAssert ({- > assert_match (' ^"Xwrite_partial" \[New\] 2L, 4B written *$' ,
411+ \ term_getline (buf , 19 ))}, 1000 )
412+ call WaitForAssert ({- > assert_match (' ^Press ENTER or type command to continue *$' ,
413+ \ term_getline (buf , 20 ))}, 1000 )
414+ call assert_equal ([' b' , ' c' ], readfile (' Xwrite_partial' ))
415+
416+ call StopVimInTerminal (buf )
417+ call delete (' Xwrite_partial' )
418+ call delete (' Xscript' )
419+ endfunc
420+
385421" Test for the :print command
386422func Test_print_cmd ()
387423 call assert_fails (' print' , ' E749:' )
0 commit comments