From cccb21df3b4c6fe0aaa99743c418aa973aeebad0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 04:10:59 +0200 Subject: Merging upstream version 2:9.1.0374. Signed-off-by: Daniel Baumann --- src/testdir/test_edit.vim | 156 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 143 insertions(+), 13 deletions(-) (limited to 'src/testdir/test_edit.vim') diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 36e0525..789e44c 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -6,8 +6,6 @@ endif source check.vim source screendump.vim - -" Needed for testing basic rightleft: Test_edit_rightleft source view_util.vim " Needs to come first until the bug in getchar() is @@ -1302,9 +1300,9 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\\", 'tnix') call assert_equal([0, 13, 1, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 1, 0], getpos('.')) + call assert_equal([0, 10, 1, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) " is the same as " is the same as call cursor(1, 1) @@ -1325,9 +1323,9 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\\", 'tnix') call assert_equal([0, 13, 1, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 1, 0], getpos('.')) + call assert_equal([0, 10, 1, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) set nostartofline call cursor(30, 11) norm! zt @@ -1338,9 +1336,9 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\\", 'tnix') call assert_equal([0, 13, 11, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) call cursor(1, 1) call feedkeys("A\\", 'tnix') call assert_equal([0, 9, 11, 0], getpos('.')) @@ -1363,9 +1361,9 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\\", 'tnix') call assert_equal([0, 13, 11, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) call feedkeys("A\\", 'tnix') - call assert_equal([0, 5, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) call cursor(1, 1) call feedkeys("A\\", 'tnix') call assert_equal([0, 9, 11, 0], getpos('.')) @@ -1964,8 +1962,8 @@ func Test_edit_ctrl_r_failed() let buf = RunVimInTerminal('', #{rows: 6, cols: 60}) - " trying to insert a dictionary produces an error - call term_sendkeys(buf, "i\={}\") + " trying to insert a blob produces an error + call term_sendkeys(buf, "i\=0z\") " ending Insert mode should put the cursor back on the ':' call term_sendkeys(buf, ":\") @@ -2046,7 +2044,10 @@ func Test_edit_revins() call setline(1, 'one two three') exe "normal! wi\nfour" call assert_equal(['one two three', 'ruof'], getline(1, '$')) - set revins& + set backspace=indent,eol,start + exe "normal! ggA\:" + call assert_equal(['one two three:ruof'], getline(1, '$')) + set revins& backspace& bw! endfunc @@ -2158,4 +2159,133 @@ func Test_edit_Ctrl_RSB() bwipe! endfunc +func s:check_backspace(expected) + let g:actual = [] + inoremap let g:actual += [getline('.')] + set backspace=indent,eol,start + + exe "normal i" .. repeat("\\", len(a:expected)) + call assert_equal(a:expected, g:actual) + + set backspace& + iunmap + unlet g:actual +endfunc + +" Test that backspace works with 'smarttab' and mixed Tabs and spaces. +func Test_edit_backspace_smarttab_mixed() + set smarttab + call NewWindow(1, 30) + setlocal tabstop=4 shiftwidth=4 + + call setline(1, "\t \t \t a") + normal! $ + call s:check_backspace([ + \ "\t \t \ta", + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "\ta", + \ "a", + \ ]) + + call CloseWindow() + set smarttab& +endfunc + +" Test that backspace works with 'smarttab' and 'varsofttabstop'. +func Test_edit_backspace_smarttab_varsofttabstop() + CheckFeature vartabs + + set smarttab + call NewWindow(1, 30) + setlocal tabstop=8 varsofttabstop=6,2,5,3 + + call setline(1, "a\t \t a") + normal! $ + call s:check_backspace([ + \ "a\t \ta", + \ "a\t a", + \ "a\ta", + \ "a a", + \ "aa", + \ "a", + \ ]) + + call CloseWindow() + set smarttab& +endfunc + +" Test that backspace works with 'smarttab' when a Tab is shown as "^I". +func Test_edit_backspace_smarttab_list() + set smarttab + call NewWindow(1, 30) + setlocal tabstop=4 shiftwidth=4 list listchars= + + call setline(1, "\t \t \t a") + normal! $ + call s:check_backspace([ + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "a", + \ ]) + + call CloseWindow() + set smarttab& +endfunc + +" Test that backspace works with 'smarttab' and 'breakindent'. +func Test_edit_backspace_smarttab_breakindent() + CheckFeature linebreak + + set smarttab + call NewWindow(3, 17) + setlocal tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5 + + call setline(1, "\t \t \t a") + normal! $ + call s:check_backspace([ + \ "\t \t \ta", + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "\ta", + \ "a", + \ ]) + + call CloseWindow() + set smarttab& +endfunc + +" Test that backspace works with 'smarttab' and virtual text. +func Test_edit_backspace_smarttab_virtual_text() + CheckFeature textprop + + set smarttab + call NewWindow(1, 50) + setlocal tabstop=4 shiftwidth=4 + + call setline(1, "\t \t \t a") + call prop_type_add('theprop', {}) + call prop_add(1, 3, {'type': 'theprop', 'text': 'text'}) + normal! $ + call s:check_backspace([ + \ "\t \t \ta", + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "\ta", + \ "a", + \ ]) + + call CloseWindow() + call prop_type_delete('theprop') + set smarttab& +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit v1.2.3