annotate src/testdir/test_backspace_opt.vim @ 18478:94223687df0e

Added tag v8.1.2233 for changeset e93cab5d0f0f27fad7882f1f412927df055b090d
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Oct 2019 04:30:05 +0100
parents f776ce5d4ed8
children b07672d13ff9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7464
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for 'backspace' settings
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 :func Exec(expr)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 let str=''
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 try
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 exec a:expr
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 catch /.*/
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 let str=v:exception
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endtry
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 return str
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 :endfunc
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 func Test_backspace_option()
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 set backspace=
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal('', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 set backspace=indent
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal('indent', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 set backspace=eol
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal('eol', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 set backspace=start
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal('start', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " Add the value
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 set backspace=
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 set backspace=indent
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal('indent', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 set backspace+=eol
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal('indent,eol', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 set backspace+=start
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_equal('indent,eol,start', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 " Delete the value
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 set backspace-=indent
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal('eol,start', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 set backspace-=start
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal('eol', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 set backspace-=eol
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 call assert_equal('', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 " Check the error
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal(0, match(Exec('set backspace=ABC'), '.*E474'))
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal(0, match(Exec('set backspace+=def'), '.*E474'))
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " NOTE: Vim doesn't check following error...
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 "call assert_equal(0, match(Exec('set backspace-=ghi'), '.*E474'))
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 " Check backwards compatibility with version 5.4 and earlier
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 set backspace=0
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal('0', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 set backspace=1
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal('1', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 set backspace=2
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal('2', &backspace)
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_false(match(Exec('set backspace=3'), '.*E474'))
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 call assert_false(match(Exec('set backspace=10'), '.*E474'))
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Cleared when 'compatible' is set
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 set compatible
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_equal('', &backspace)
8796
fb764adba294 commit https://github.com/vim/vim/commit/e9c07270031e312082604d3505650f185aa65948
Christian Brabandt <cb@256bit.org>
parents: 8564
diff changeset
56 set nocompatible viminfo+=nviminfo
7464
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 endfunc
1e47dd710211 commit https://github.com/vim/vim/commit/27a82e31ee9acedb6922093b2764f7f6860b0f91
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
16658
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
59 " Test with backspace set to the non-compatible setting
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
60 func Test_backspace_ctrl_u()
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
61 new
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
62 call append(0, [
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
63 \ "1 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
64 \ "2 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
65 \ "3 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
66 \ "4 this should be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
67 \ "5 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
68 \ "6 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
69 \ "7 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
70 \ "8 this shouldn't be deleted (not touched yet)"])
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
71 call cursor(2, 1)
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
72
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
73 set compatible
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
74 set backspace=2
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
75
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
76 exe "normal Avim1\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
77 exe "normal Avim2\<C-G>u\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
78
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
79 set cpo-=<
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
80 inoremap <c-u> <left><c-u>
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
81 exe "normal Avim3\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
82 iunmap <c-u>
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
83 exe "normal Avim4\<C-U>\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
84
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
85 " Test with backspace set to the compatible setting
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
86 set backspace= visualbell
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
87 exe "normal A vim5\<Esc>A\<C-U>\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
88 exe "normal A vim6\<Esc>Azwei\<C-G>u\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
89
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
90 inoremap <c-u> <left><c-u>
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
91 exe "normal A vim7\<C-U>\<C-U>\<Esc>\<CR>"
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
92
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
93 call assert_equal([
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
94 \ "1 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
95 \ "2 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
96 \ "3 this shouldn't be deleted",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
97 \ "4 this should be deleted3",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
98 \ "",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
99 \ "6 this shouldn't be deleted vim5",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
100 \ "7 this shouldn't be deleted vim6",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
101 \ "8 this shouldn't be deleted (not touched yet) vim7",
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
102 \ ""], getline(1, '$'))
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
103
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
104 set compatible&vim
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
105 set visualbell&vim
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
106 set backspace&vim
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
107 close!
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
108 endfunc
f776ce5d4ed8 patch 8.1.1331: test 29 is old style
Bram Moolenaar <Bram@vim.org>
parents: 9909
diff changeset
109
9909
3ee84d270ea7 commit https://github.com/vim/vim/commit/9e4d8215d386100ab660d7d11e6620fd148b605e
Christian Brabandt <cb@256bit.org>
parents: 8796
diff changeset
110 " vim: shiftwidth=2 sts=2 expandtab