annotate src/testdir/test_blockedit.vim @ 25072:bd46322bea66 v8.2.3073

patch 8.2.3073: when cursor is move for block append wrong text is inserted Commit: https://github.com/vim/vim/commit/4067bd3604215b48e4b4201e28f9e401b08418e4 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 29 18:54:35 2021 +0200 patch 8.2.3073: when cursor is move for block append wrong text is inserted Problem: When cursor is move for block append wrong text is inserted. Solution: Calculate an offset. (Christian Brabandt, closes https://github.com/vim/vim/issues/8433, closes #8288)
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Jun 2021 19:00:05 +0200
parents 08940efa6b4e
children 294736db2561
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13620
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for block inserting
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_blockinsert_indent()
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 new
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 filetype plugin indent on
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 setlocal sw=2 et ft=vim
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call setline(1, ['let a=[', ' ''eins'',', ' ''zwei'',', ' ''drei'']'])
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call cursor(2, 3)
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 exe "norm! \<c-v>2jI\\ \<esc>"
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call assert_equal(['let a=[', ' \ ''eins'',', ' \ ''zwei'',', ' \ ''drei'']'],
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 \ getline(1,'$'))
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " reset to sane state
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 filetype off
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 bwipe!
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 endfunc
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
13814
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
17 func Test_blockinsert_delete()
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
18 new
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
19 let _bs = &bs
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
20 set bs=2
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
21 call setline(1, ['case Arg is ', ' when Name_Async,', ' when Name_Num_Gangs,', 'end if;'])
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
22 exe "norm! ggjVj\<c-v>$o$A\<bs>\<esc>"
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
23 "call feedkeys("Vj\<c-v>$o$A\<bs>\<esc>", 'ti')
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
24 call assert_equal(["case Arg is ", " when Name_Async", " when Name_Num_Gangs,", "end if;"],
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
25 \ getline(1,'$'))
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
26 " reset to sane state
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
27 let &bs = _bs
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
28 bwipe!
7ed76dcf0d94 patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents: 13620
diff changeset
29 endfunc
13620
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
25072
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
31 func Test_blockappend_eol_cursor()
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
32 new
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
33 " Test 1 Move 1 char left
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
34 call setline(1, ['aaa', 'bbb', 'ccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
35 exe "norm! gg$\<c-v>2jA\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
36 call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
37 " Test 2 Move 2 chars left
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
38 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
39 call setline(1, ['aaa', 'bbb', 'ccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
40 exe "norm! gg$\<c-v>2jA\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
41 call assert_equal(['axaa', 'bxbb', 'cxcc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
42 " Test 3 Move 3 chars left (outside of the visual selection)
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
43 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
44 call setline(1, ['aaa', 'bbb', 'ccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
45 exe "norm! ggl$\<c-v>2jA\<left>\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
46 call assert_equal(['xaaa', 'bbb', 'ccc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47 bw!
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
48 endfunc
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
49
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
50 func Test_blockappend_eol_cursor2()
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
51 new
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
52 " Test 1 Move 1 char left
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
53 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
54 exe "norm! gg\<c-v>$2jA\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
55 call assert_equal(['aaaaxa', 'bbbx', 'ccccxc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
56 " Test 2 Move 2 chars left
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
57 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
58 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
59 exe "norm! gg\<c-v>$2jA\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
60 call assert_equal(['aaaxaa', 'bbbx', 'cccxcc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
61 " Test 3 Move 3 chars left (to the beginning of the visual selection)
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
62 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
63 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
64 exe "norm! gg\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
65 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
66 " Test 4 Move 3 chars left (outside of the visual selection)
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
67 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
68 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
69 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
70 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
71 " Test 5 Move 4 chars left (outside of the visual selection)
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
72 sil %d
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
73 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
74 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>\<left>x\<esc>"
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
75 call assert_equal(['axaaaa', 'bxbb', 'cxcccc'], getline(1, '$'))
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
76 bw!
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
77 endfunc
bd46322bea66 patch 8.2.3073: when cursor is move for block append wrong text is inserted
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
78
13620
4faf77b96432 patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 " vim: shiftwidth=2 sts=2 expandtab