File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -641,4 +641,22 @@ func Test_execute_reg_as_ex_cmd()
641641 call assert_equal (repeat (' abcdefghijklmnopqrstuvwxyz' , 312 ), str)
642642endfunc
643643
644+ " Test for clipboard registers with ASCII NUL
645+ func Test_clipboard_nul ()
646+ CheckFeature clipboard_working
647+ new
648+
649+ " Test for putting ASCII NUL into the clipboard
650+ set clipboard = unnamed
651+ call append (0 , " \n test" )
652+ normal ggyyp
653+ call assert_equal (" ^@test^@" , strtrans (getreg (' *' )))
654+ call assert_equal (getline (1 ), getline (2 ))
655+ let b = split (execute (" :reg *" ), " \n " )
656+ call assert_match (' "\*\s*\^@test\^J' ,b [1 ])
657+
658+ set clipboard &vim
659+ bwipe!
660+ endfunc
661+
644662" vim: shiftwidth = 2 sts = 2 expandtab
Original file line number Diff line number Diff line change @@ -754,6 +754,8 @@ static char *(features[]) =
754754
755755static int included_patches [] =
756756{ /* Add new patch number below this line */
757+ /**/
758+ 1039 ,
757759/**/
758760 1038 ,
759761/**/
Original file line number Diff line number Diff line change @@ -422,7 +422,7 @@ clip_mch_request_selection(Clipboard_T *cbd)
422422 }
423423 }
424424
425- if (str != NULL && * str != NUL )
425+ if (str != NULL && metadata . txtlen != 0 )
426426 {
427427 char_u * temp_clipboard ;
428428
@@ -543,7 +543,7 @@ clip_mch_set_selection(Clipboard_T *cbd)
543543
544544 if (lpszMem )
545545 {
546- vim_strncpy ((char_u * )lpszMem , str , metadata .txtlen );
546+ mch_memmove ((char_u * )lpszMem , str , metadata .txtlen );
547547 GlobalUnlock (hMem );
548548 }
549549 }
You can’t perform that action at this time.
0 commit comments