summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_edit.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-25 16:34:51 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-25 16:34:51 +0100
commit0185c7701434f1fbbf83fecd6384a19c1d2fc44e (patch)
tree3c60cd43525516b290fa4a0f9adb6f7c3d31bd64 /src/testdir/test_edit.vim
parentab01adf7c65b4ee350b402ab3ef1e7dfa5e074f1 (diff)
patch 9.1.0204: Backspace inserts spaces with virtual text and 'smarttab'v9.1.0204
Problem: Backspace inserts spaces with virtual text and 'smarttab'. Solution: Ignore virtual text and wrapping when backspacing. (zeertzjq) related: neovim/neovim#28005 closes: #14296 Co-authored-by: VanaIgr <vanaigranov@gmail.com> Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_edit.vim')
-rw-r--r--src/testdir/test_edit.vim111
1 files changed, 109 insertions, 2 deletions
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index 36e0525563..2ec7cde8d2 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
@@ -2158,4 +2156,113 @@ func Test_edit_Ctrl_RSB()
bwipe!
endfunc
+func s:check_backspace(expected)
+ let g:actual = []
+ inoremap <buffer> <F2> <Cmd>let g:actual += [getline('.')]<CR>
+ set backspace=indent,eol,start
+
+ exe "normal $i" .. repeat("\<BS>\<F2>", len(a:expected))
+ call assert_equal(a:expected, g:actual)
+
+ set backspace&
+ iunmap <buffer> <F2>
+ 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