annotate src/testdir/test_ex_z.vim @ 32288:8201b0fcea02 v9.0.1476

patch 9.0.1476: lines put in non-current window are not displayed Commit: https://github.com/vim/vim/commit/e7f05a8780426dc7af247419c6d02d5f1e896689 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 22 15:35:28 2023 +0100 patch 9.0.1476: lines put in non-current window are not displayed Problem: Lines put in non-current window are not displayed. (Marius Gedminas) Solution: Don't increment the topline when inserting just above it. (closes #12212)
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Apr 2023 16:45:05 +0200
parents 0f93e9423890
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11303
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test :z
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_z()
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 call setline(1, range(1, 100))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 let a = execute('20z3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call assert_equal("\n20\n21\n22", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call assert_equal(22, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " 'window' should be set to the {count} value.
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call assert_equal(3, &window)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " If there is only one window, then twice the amount of 'scroll' is used.
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 set scroll=2
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let a = execute('20z')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal("\n20\n21\n22\n23", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal(23, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let a = execute('20z+3')
25729
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
19 " FIXME: I would expect the same result as '20z3' since 'help z'
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
20 " says: Specifying no mark at all is the same as "+".
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
21 " However it " gives "\n21\n22\n23" instead. Bug in Vim or in ":help :z"?
11303
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 "call assert_equal("\n20\n21\n22", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 "call assert_equal(22, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let a = execute('20z-3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call assert_equal("\n18\n19\n20", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 let a = execute('20z=3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_match("^\n18\n19\n-\\+\n20\n-\\+\n21\n22$", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 let a = execute('20z^3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call assert_equal("\n14\n15\n16\n17", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal(17, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let a = execute('20z.3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal("\n19\n20\n21", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 call assert_equal(21, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 let a = execute('20z#3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call assert_equal("\n 20 20\n 21 21\n 22 22", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(22, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 let a = execute('20z#-3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call assert_equal("\n 18 18\n 19 19\n 20 20", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 let a = execute('20z#=3')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_match("^\n 18 18\n 19 19\n-\\+\n 20 20\n-\\+\n 21 21\n 22 22$", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " Test with {count} bigger than the number of lines in buffer.
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 let a = execute('20z1000')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 call assert_match("^\n20\n21\n.*\n99\n100$", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call assert_equal(100, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 let a = execute('20z-1000')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 let a = execute('20z=1000')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call assert_match("^\n1\n.*\n-\\+\n20\n-\\\+\n.*\n100$", a)
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal(20, line('.'))
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
25729
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
65 " Tests with multiple windows.
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
66 5split
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
67 call setline(1, range(1, 100))
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
68 " Without a count, the number line is window height - 3.
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
69 let a = execute('20z')
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
70 call assert_equal("\n20\n21", a)
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
71 call assert_equal(21, line('.'))
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
72 " If window height - 3 is less than 1, it should be clamped to 1.
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
73 resize 2
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
74 let a = execute('20z')
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
75 call assert_equal("\n20", a)
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
76 call assert_equal(20, line('.'))
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
77
11303
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call assert_fails('20z=a', 'E144:')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 set window& scroll&
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 bw!
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 endfunc
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
25729
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
84 " :z! is the same as :z but count uses the Vim window height when not specified.
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
85 func Test_z_bang()
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
86 4split
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
87 call setline(1, range(1, 20))
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
88
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
89 let a = execute('10z!')
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
90 call assert_equal("\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20", a)
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
91
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
92 let a = execute('10z!#')
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
93 call assert_equal("\n 10 10\n 11 11\n 12 12\n 13 13\n 14 14\n 15 15\n 16 16\n 17 17\n 18 18\n 19 19\n 20 20", a)
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
94
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
95 let a = execute('10z!3')
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
96 call assert_equal("\n10\n11\n12", a)
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
97
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
98 %bwipe!
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
99 endfunc
0f93e9423890 patch 8.2.3400: ":z!" is not supported
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
100
11372
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
101 func Test_z_overflow()
11303
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 " This used to access invalid memory as a result of an integer overflow
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 " and freeze vim.
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 normal ox
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 normal Heat
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 z777777776666666
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 ')
ef32a5c74515 patch 8.0.0537: illegal memory access with :z and large count
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 endfunc
11372
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
109
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
110 func Test_z_negative_lnum()
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
111 new
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
112 z^
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
113 call assert_equal(1, line('.'))
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
114 bwipe!
1074f58e1673 patch 8.0.0571: negative line number when using :z^ in an empty buffer
Christian Brabandt <cb@256bit.org>
parents: 11303
diff changeset
115 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 11372
diff changeset
116
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 11372
diff changeset
117 " vim: shiftwidth=2 sts=2 expandtab