Mercurial > vim
annotate src/testdir/test_blockedit.vim @ 26307:294736db2561 v8.2.3684
patch 8.2.3684: blockwise insert does not handle autoindent properly
Commit: https://github.com/vim/vim/commit/e9b0b40b7978f683977922233b42dd439ef31920
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 27 13:28:24 2021 +0000
patch 8.2.3684: blockwise insert does not handle autoindent properly
Problem: Blockwise insert does not handle autoindent properly.
Solution: Adjust text column for indent. (closes https://github.com/vim/vim/issues/9229)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Nov 2021 14:30:03 +0100 |
parents | bd46322bea66 |
children | 74e706afae3f |
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 |
26307
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
17 func Test_blockinsert_autoindent() |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
18 new |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
19 let lines =<< trim END |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
20 var d = { |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
21 a: () => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
22 b: () => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
23 c: () => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
24 } |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
25 END |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
26 call setline(1, lines) |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
27 filetype plugin indent on |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
28 setlocal sw=2 et ft=vim |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
29 setlocal indentkeys+=: |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
30 exe "norm! 2Gf)\<c-v>2jA: asdf\<esc>" |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
31 let expected =<< trim END |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
32 var d = { |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
33 a: (): asdf => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
34 b: (): asdf => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
35 c: (): asdf => 0, |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
36 } |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
37 END |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
38 call assert_equal(expected, getline(1, 5)) |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
39 |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
40 filetype off |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
41 bwipe! |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
42 endfunc |
294736db2561
patch 8.2.3684: blockwise insert does not handle autoindent properly
Bram Moolenaar <Bram@vim.org>
parents:
25072
diff
changeset
|
43 |
13814
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
44 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
|
45 new |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
46 let _bs = &bs |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
47 set bs=2 |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
48 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
|
49 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
|
50 "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
|
51 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
|
52 \ getline(1,'$')) |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
53 " 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
|
54 let &bs = _bs |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
55 bwipe! |
7ed76dcf0d94
patch 8.0.1779: deleting in a block selection causes problems
Christian Brabandt <cb@256bit.org>
parents:
13620
diff
changeset
|
56 endfunc |
13620
4faf77b96432
patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
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
|
58 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
|
59 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
|
60 " 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
|
61 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
|
62 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
|
63 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
|
64 " 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 " 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 |
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 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
|
78 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
|
79 " 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
|
80 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
|
81 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
|
82 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
|
83 " 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 " 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 " 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 " 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 |
13620
4faf77b96432
patch 8.0.1682: auto indenting breaks inserting a block
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 " vim: shiftwidth=2 sts=2 expandtab |