@@ -844,7 +844,7 @@ func! Test_normal18_z_fold()
844844 norm! j
845845 call assert_equal (' 52' , getline (' .' ))
846846
847- " zA on a opened fold when foldenale is not set
847+ " zA on a opened fold when foldenable is not set
848848 50
849849 set nofoldenable
850850 norm! zA
@@ -906,7 +906,7 @@ func! Test_normal18_z_fold()
906906 norm! j
907907 call assert_equal (' 55' , getline (' .' ))
908908
909- " 2) do not close fold under curser
909+ " 2) do not close fold under cursor
910910 51
911911 set nofoldenable
912912 norm! zx
@@ -1772,18 +1772,60 @@ fun! Test_normal34_g_cmd3()
17721772 if ! has (" multi_byte" )
17731773 return
17741774 endif
1775+
17751776 " Test for g8
17761777 new
1777- call append (0 , ' abcdefghijklmnopqrstuvwxyzäüö' )
1778- let a = execute (' :norm! 1gg$g8' )
1779- call assert_equal (' c3 b6 ' , a [1 :])
1778+ let a = execute (' :norm! 1G0g8' )
1779+ call assert_equal (" \n NUL" , a )
1780+
1781+ call setline (1 , ' abcdefghijklmnopqrstuvwxyzäüö' )
1782+ let a = execute (' :norm! 1G$g8' )
1783+ call assert_equal (" \n c3 b6 " , a )
1784+
1785+ call setline (1 , " a\u0302 " )
1786+ let a = execute (' :norm! 1G0g8' )
1787+ call assert_equal (" \n 61 + cc 82 " , a )
17801788
1781- " Test for gp gP
1782- call append (1 , range (1 ,10 ))
17831789 " clean up
17841790 bw !
17851791endfunc
17861792
1793+ func Test_normal_8g8 ()
1794+ if ! has (" multi_byte" )
1795+ return
1796+ endif
1797+ new
1798+
1799+ " Test 8g8 which finds invalid utf8 at or after the cursor.
1800+
1801+ " With invalid byte.
1802+ call setline (1 , " ___\xff ___" )
1803+ norm! 1 G08g8g
1804+ call assert_equal ([0 , 1 , 4 , 0 , 1 ], getcurpos ())
1805+
1806+ " With invalid byte before the cursor.
1807+ call setline (1 , " ___\xff ___" )
1808+ norm! 1 G$h8g8g
1809+ call assert_equal ([0 , 1 , 6 , 0 , 9 ], getcurpos ())
1810+
1811+ " With truncated sequence.
1812+ call setline (1 , " ___\xE2\x82 ___" )
1813+ norm! 1 G08g8g
1814+ call assert_equal ([0 , 1 , 4 , 0 , 1 ], getcurpos ())
1815+
1816+ " With overlong sequence.
1817+ call setline (1 , " ___\xF0\x82\x82\xAC ___" )
1818+ norm! 1 G08g8g
1819+ call assert_equal ([0 , 1 , 4 , 0 , 1 ], getcurpos ())
1820+
1821+ " With valid utf8.
1822+ call setline (1 , " café" )
1823+ norm! 1 G08g8
1824+ call assert_equal ([0 , 1 , 1 , 0 , 1 ], getcurpos ())
1825+
1826+ bw !
1827+ endfunc
1828+
17871829fun ! Test_normal35_g_cmd4 ()
17881830 " Test for g<
17891831 " Cannot capture its output,
0 commit comments