Mercurial > vim
annotate src/testdir/test_virtualedit.vim @ 15975:915ed7ca92fa v8.1.0993
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
commit https://github.com/vim/vim/commit/772153f8d85c83e08427d93460a676d7f079f002
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 4 12:09:49 2019 +0100
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Problem: ch_read() may return garbage if terminating NL is missing.
Solution: Add terminating NUL. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4065)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 04 Mar 2019 12:15:05 +0100 |
parents | 2dcaa860e3fc |
children | 26256dcadd77 |
rev | line source |
---|---|
12164
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for 'virtualedit'. |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func Test_yank_move_change() |
12279
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
4 new |
12164
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 call setline(1, [ |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 \ "func foo() error {", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 \ "\tif n, err := bar();", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 \ "\terr != nil {", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 \ "\t\treturn err", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 \ "\t}", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 \ "\tn = n * n", |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 \ ]) |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 set virtualedit=all |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 set ts=4 |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 function! MoveSelectionDown(count) abort |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 normal! m` |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 silent! exe "'<,'>move'>+".a:count |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 norm! `` |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 endfunction |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 xmap ]e :<C-U>call MoveSelectionDown(v:count1)<CR> |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 2 |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 normal 2gg |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 normal J |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 normal jVj |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 normal ]e |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 normal ce |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 bwipe! |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 set virtualedit= |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 set ts=8 |
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 endfunc |
12279
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
32 |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
33 func Test_paste_end_of_line() |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
34 new |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
35 set virtualedit=all |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
36 call setline(1, ['456', '123']) |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
37 normal! gg0"ay$ |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
38 exe "normal! 2G$lllA\<C-O>:normal! \"agP\r" |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
39 call assert_equal('123456', getline(2)) |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
40 |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
41 bwipe! |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
42 set virtualedit= |
57e0b701611e
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
43 endfunc |
13786
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
44 |
14216
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
45 func Test_replace_end_of_line() |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
46 new |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
47 set virtualedit=all |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
48 call setline(1, range(20)) |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
49 exe "normal! gg2jv10lr-" |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
50 call assert_equal(["1", "-----------", "3"], getline(2,4)) |
15607
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
14216
diff
changeset
|
51 call setline(1, range(20)) |
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
14216
diff
changeset
|
52 exe "normal! gg2jv10lr\<c-k>hh" |
2dcaa860e3fc
patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
14216
diff
changeset
|
53 call assert_equal(["1", "───────────", "3"], getline(2,4)) |
14216
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
54 |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
55 bwipe! |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
56 set virtualedit= |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
57 endfunc |
12bdbf9f7e20
patch 8.1.0125: virtual edit replace with multi-byte fails at end of line
Christian Brabandt <cb@256bit.org>
parents:
13786
diff
changeset
|
58 |
13786
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
59 func Test_edit_CTRL_G() |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
60 new |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
61 set virtualedit=insert |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
62 call setline(1, ['123', '1', '12']) |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
63 exe "normal! ggA\<c-g>jx\<c-g>jx" |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
64 call assert_equal(['123', '1 x', '12 x'], getline(1,'$')) |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
65 |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
66 set virtualedit=all |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
67 %d_ |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
68 call setline(1, ['1', '12']) |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
69 exe "normal! ggllix\<c-g>jx" |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
70 call assert_equal(['1 x', '12x'], getline(1,'$')) |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
71 |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
72 |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
73 bwipe! |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
74 set virtualedit= |
0fa21ba32e21
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Christian Brabandt <cb@256bit.org>
parents:
12279
diff
changeset
|
75 endfunc |