From 7e386308746e61cfdf0ca757a40122cbbceb7feb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 26 Mar 2024 05:42:56 +0800 Subject: vim-patch:9.1.0204: Backspace inserts spaces with virtual text and 'smarttab' (#28032) Problem: Backspace inserts spaces with virtual text and 'smarttab'. Solution: Ignore virtual text and wrapping when backspacing. (zeertzjq) related: neovim/neovim#28005 closes: vim/vim#14296 https://github.com/vim/vim/commit/0185c7701434f1fbbf83fecd6384a19c1d2fc44e Co-authored-by: VanaIgr --- test/old/testdir/test_edit.vim | 111 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim index 67143ab524..8281b3d495 100644 --- a/test/old/testdir/test_edit.vim +++ b/test/old/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 @@ -2153,4 +2151,113 @@ 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() + call NewWindow(1, 30) + setlocal smarttab tabstop=4 shiftwidth=4 + call setline(1, "\t \t \t a") + call s:check_backspace([ + \ "\t \t \ta", + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "\ta", + \ "a", + \ ]) + + call CloseWindow() +endfunc + +" Test that backspace works with 'smarttab' and 'varsofttabstop'. +func Test_edit_backspace_smarttab_varsofttabstop() + CheckFeature vartabs + + call NewWindow(1, 30) + setlocal smarttab tabstop=8 varsofttabstop=6,2,5,3 + call setline(1, "a\t \t a") + call s:check_backspace([ + \ "a\t \ta", + \ "a\t a", + \ "a\ta", + \ "a a", + \ "aa", + \ "a", + \ ]) + + call CloseWindow() +endfunc + +" Test that backspace works with 'smarttab' when a Tab is shown as "^I". +func Test_edit_backspace_smarttab_list() + call NewWindow(1, 30) + setlocal smarttab tabstop=4 shiftwidth=4 list listchars= + call setline(1, "\t \t \t a") + call s:check_backspace([ + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "a", + \ ]) + + call CloseWindow() +endfunc + +" Test that backspace works with 'smarttab' and 'breakindent'. +func Test_edit_backspace_smarttab_breakindent() + CheckFeature linebreak + + call NewWindow(3, 17) + setlocal smarttab tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5 + call setline(1, "\t \t \t a") + call s:check_backspace([ + \ "\t \t \ta", + \ "\t \t a", + \ "\t \t a", + \ "\t \ta", + \ "\t a", + \ "\ta", + \ "a", + \ ]) + + call CloseWindow() +endfunc + +" Test that backspace works with 'smarttab' and virtual text. +func Test_edit_backspace_smarttab_virtual_text() + CheckFeature textprop + + call NewWindow(1, 50) + setlocal smarttab 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'}) + 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') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit