annotate src/testdir/test_bufline.vim @ 35167:6dddafdbe6f9 default tip

Added tag v9.1.0409 for changeset 0b259135fb3a4ce87fc1ff0673ae9b61cb7ed555
author Christian Brabandt <cb@256bit.org>
date Sun, 12 May 2024 00:15:05 +0200
parents 87ff5e71d3c2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
1 " Tests for setbufline(), getbufline(), appendbufline(), deletebufline()
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
12568
440d934bd616 patch 8.0.1162: shared script for tests cannot be included twice
Christian Brabandt <cb@256bit.org>
parents: 12351
diff changeset
3 source shared.vim
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
4 source screendump.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
5 source check.vim
12351
4e61b77cd96f patch 8.0.1055: bufline test hangs on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12347
diff changeset
6
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_setbufline_getbufline()
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
8 " similar to Test_set_get_bufline()
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 new
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 hide
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal(['foo'], getbufline(b, 1))
31164
7831da568864 patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents: 31160
diff changeset
14 call assert_equal('foo', getbufoneline(b, 1))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
15 call assert_equal(['bar'], getbufline(b, '$'))
31164
7831da568864 patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents: 31160
diff changeset
16 call assert_equal('bar', getbufoneline(b, '$'))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 exe "bd!" b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal([], getbufline(b, 1, 2))
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 split Xtest
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call setline(1, ['a', 'b', 'c'])
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 let b = bufnr('%')
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 wincmd w
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
25
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
26 call assert_equal(1, setbufline(b, 5, 'x'))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal(1, setbufline(b, 5, ['x']))
31004
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
28 call assert_equal(0, setbufline(b, 5, []))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
29 call assert_equal(0, setbufline(b, 5, test_null_list()))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
30
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
31 call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
32 call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
33 call assert_equal(1, []->setbufline(bufnr('$') + 1, 1))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
34 call assert_equal(1, test_null_list()->setbufline(bufnr('$') + 1, 1))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
35
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
36 call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
37
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call assert_equal(0, setbufline(b, 4, ['d', 'e']))
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
39 call assert_equal(['c'], b->getbufline(3))
31164
7831da568864 patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents: 31160
diff changeset
40 call assert_equal('c', b->getbufoneline(3))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call assert_equal(['d'], getbufline(b, 4))
31164
7831da568864 patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents: 31160
diff changeset
42 call assert_equal('d', getbufoneline(b, 4))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call assert_equal(['e'], getbufline(b, 5))
31164
7831da568864 patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents: 31160
diff changeset
44 call assert_equal('e', getbufoneline(b, 5))
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call assert_equal([], getbufline(b, 6))
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
46 call assert_equal([], getbufline(b, 2, 1))
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47
23875
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
48 if has('job')
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
49 call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()])
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
50 call assert_equal(["function('eval')",
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
51 \ "{'key': 123}",
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
52 \ "no process"],
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
53 \ getbufline(b, 2, 4))
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23788
diff changeset
54 endif
12319
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 exe "bwipe! " . b
c7e95667d14b patch 8.0.1039: cannot change a line in not current buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunc
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
57
12794
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
58 func Test_setbufline_getbufline_fold()
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
59 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
60 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
61 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
62 new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
63 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
64 call assert_equal(['foo'], getbufline(b, 1))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
65 call assert_equal(['bar'], getbufline(b, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
66 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
67 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
68 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
69 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
70
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
71 func Test_setbufline_getbufline_fold_tab()
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
72 split Xtest
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
73 setlocal foldmethod=expr foldexpr=0
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
74 let b = bufnr('%')
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
75 tab new
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
76 call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
77 call assert_equal(['foo'], getbufline(b, 1))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
78 call assert_equal(['bar'], getbufline(b, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
79 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
80 exe "bwipe!" b
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
81 bwipe!
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
82 endfunc
d4fc8a7dc7d9 patch 8.0.1274: setbufline() fails when using folding
Christian Brabandt <cb@256bit.org>
parents: 12568
diff changeset
83
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
84 func Test_setline_startup()
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
85 let cmd = GetVimCommand('Xscript')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
86 if cmd == ''
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
87 return
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
88 endif
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 29875
diff changeset
89 call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript', 'D')
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
90 call system(cmd)
30158
008808e60963 patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents: 30110
diff changeset
91 sleep 50m
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
92 call assert_equal(['Hello'], readfile('Xtest'))
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
93
31004
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
94 call assert_equal(0, setline(1, []))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
95 call assert_equal(0, setline(1, test_null_list()))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
96 call assert_equal(0, setline(5, []))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
97 call assert_equal(0, setline(6, test_null_list()))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
98
12347
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
99 call delete('Xtest')
61a9642297cc patch 8.0.1053: setline() does not work on startup
Christian Brabandt <cb@256bit.org>
parents: 12319
diff changeset
100 endfunc
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
101
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
102 func Test_appendbufline()
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
103 new
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
104 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
105 hide
31160
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
106
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
107 new
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
108 call setline(1, ['line1', 'line2', 'line3'])
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
109 normal! 2gggg
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
110 call assert_equal(2, line("''"))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
111
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
112 call assert_equal(0, appendbufline(b, 0, ['foo', 'bar']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
113 call assert_equal(['foo'], getbufline(b, 1))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
114 call assert_equal(['bar'], getbufline(b, 2))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
115 call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
31160
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
116 call assert_equal(0, appendbufline(b, 0, 'baz'))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
117 call assert_equal(['baz', 'foo', 'bar'], getbufline(b, 1, 3))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
118
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
119 " appendbufline() in a hidden buffer shouldn't move marks in current window.
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
120 call assert_equal(2, line("''"))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
121 bwipe!
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
122
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
123 exe "bd!" b
31160
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
124 call assert_equal([], getbufline(b, 1, 3))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
125
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
126 split Xtest
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
127 call setline(1, ['a', 'b', 'c'])
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
128 let b = bufnr('%')
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
129 wincmd w
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
130
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
131 call assert_equal(1, appendbufline(b, -1, 'x'))
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
132 call assert_equal(1, appendbufline(b, -1, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
133 call assert_equal(1, appendbufline(b, -1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
134 call assert_equal(1, appendbufline(b, -1, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
135
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
136 call assert_equal(1, appendbufline(b, 4, 'x'))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
137 call assert_equal(1, appendbufline(b, 4, ['x']))
31004
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
138 call assert_equal(0, appendbufline(b, 4, []))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
139 call assert_equal(0, appendbufline(b, 4, test_null_list()))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
140
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
141 call assert_equal(1, appendbufline(1234, 1, 'x'))
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
142 call assert_equal(1, appendbufline(1234, 1, ['x']))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
143 call assert_equal(1, appendbufline(1234, 1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
144 call assert_equal(1, appendbufline(1234, 1, test_null_list()))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
145
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
146 call assert_equal(0, appendbufline(b, 1, []))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
147 call assert_equal(0, appendbufline(b, 1, test_null_list()))
31004
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
148 call assert_equal(0, appendbufline(b, 3, []))
eb145a4d6bf8 patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
149 call assert_equal(0, appendbufline(b, 3, test_null_list()))
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
150
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
151 call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
152
14039
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
153 call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
154 call assert_equal(['c'], getbufline(b, 3))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
155 call assert_equal(['d'], getbufline(b, 4))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
156 call assert_equal(['e'], getbufline(b, 5))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
157 call assert_equal([], getbufline(b, 6))
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
158 exe "bwipe! " . b
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
159 endfunc
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
160
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
161 func Test_appendbufline_no_E315()
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
162 let after =<< trim [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
163 set stl=%f ls=2
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
164 new
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
165 let buf = bufnr("%")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
166 quit
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
167 vsp
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
168 exec "buffer" buf
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
169 wincmd w
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
170 call appendbufline(buf, 0, "abc")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
171 redraw
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
172 while getbufline(buf, 1)[0] =~ "^\\s*$"
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
173 sleep 10m
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
174 endwhile
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
175 au VimLeavePre * call writefile([v:errmsg], "Xerror")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
176 au VimLeavePre * call writefile(["done"], "Xdone")
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
177 qall!
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
178 [CODE]
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16668
diff changeset
179
14826
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
180 if !RunVim([], after, '--clean')
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
181 return
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
182 endif
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
183 call assert_notmatch("^E315:", readfile("Xerror")[0])
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
184 call assert_equal("done", readfile("Xdone")[0])
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
185 call delete("Xerror")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
186 call delete("Xdone")
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
187 endfunc
75d474a8868a patch 8.1.0425: ml_get error and crash with appendbufline()
Christian Brabandt <cb@256bit.org>
parents: 14043
diff changeset
188
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
189 func Test_deletebufline()
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
190 new
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
191 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
192 call setline(1, ['aaa', 'bbb', 'ccc'])
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
193 hide
31160
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
194
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
195 new
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
196 call setline(1, ['line1', 'line2', 'line3'])
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
197 normal! 2gggg
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
198 call assert_equal(2, line("''"))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
199
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
200 call assert_equal(0, deletebufline(b, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
201 call assert_equal(['aaa', 'ccc'], getbufline(b, 1, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
202 call assert_equal(0, deletebufline(b, 2, 8))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
203 call assert_equal(['aaa'], getbufline(b, 1, 2))
31160
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
204
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
205 " deletebufline() in a hidden buffer shouldn't move marks in current window.
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
206 call assert_equal(2, line("''"))
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
207 bwipe!
eff0d98467e3 patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents: 31012
diff changeset
208
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
209 exe "bd!" b
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
210 call assert_equal(1, b->deletebufline(1))
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
211
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
212 call assert_equal(1, deletebufline(-1, 1))
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
213
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
214 split Xtest
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
215 call setline(1, ['a', 'b', 'c'])
16668
81be817c9d9a patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 16368
diff changeset
216 call cursor(line('$'), 1)
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
217 let b = bufnr('%')
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
218 wincmd w
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
219 call assert_equal(1, deletebufline(b, 4))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
220 call assert_equal(0, deletebufline(b, 1))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
221 call assert_equal(['b', 'c'], getbufline(b, 1, 2))
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
222 exe "bwipe! " . b
23893
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
223
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
224 edit XbufOne
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
225 let one = bufnr()
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
226 call setline(1, ['a', 'b', 'c'])
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
227 setlocal nomodifiable
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
228 split XbufTwo
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
229 let two = bufnr()
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
230 call assert_fails('call deletebufline(one, 1)', 'E21:')
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
231 call assert_equal(two, bufnr())
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
232 bwipe! XbufTwo
a433d0070c45 patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents: 23875
diff changeset
233 bwipe! XbufOne
14043
cbad3b3f46b2 patch 8.1.0039: cannot easily delete lines in another buffer
Christian Brabandt <cb@256bit.org>
parents: 14039
diff changeset
234 endfunc
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
235
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
236 func Test_appendbufline_redraw()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
237 CheckScreendump
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17518
diff changeset
238
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
239 let lines =<< trim END
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
240 new foo
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
241 let winnr = 'foo'->bufwinnr()
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
242 let buf = bufnr('foo')
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
243 wincmd p
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
244 call appendbufline(buf, '$', range(1,200))
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
245 exe winnr .. 'wincmd w'
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
246 norm! G
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
247 wincmd p
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
248 call deletebufline(buf, 1, '$')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
249 call appendbufline(buf, '$', 'Hello Vim world...')
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
250 END
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 29875
diff changeset
251 call writefile(lines, 'XscriptMatchCommon', 'D')
17518
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
252 let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10})
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
253 call VerifyScreenDump(buf, 'Test_appendbufline_1', {})
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
254
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
255 call StopVimInTerminal(buf)
bfc5a2962f38 patch 8.1.1757: text added with appendbufline() isn't displayed
Bram Moolenaar <Bram@vim.org>
parents: 16720
diff changeset
256 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
257
28948
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
258 func Test_setbufline_select_mode()
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
259 new
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
260 call setline(1, ['foo', 'bar'])
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
261 call feedkeys("j^v2l\<C-G>", 'nx')
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
262
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
263 let bufnr = bufadd('Xdummy')
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
264 call bufload(bufnr)
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
265 call setbufline(bufnr, 1, ['abc'])
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
266
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
267 call feedkeys("x", 'nx')
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
268 call assert_equal(['foo', 'x'], getline(1, 2))
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
269
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
270 exe "bwipe! " .. bufnr
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
271 bwipe!
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
272 endfunc
b907d4a36318 patch 8.2.4996: setbufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
273
28960
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
274 func Test_deletebufline_select_mode()
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
275 new
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
276 call setline(1, ['foo', 'bar'])
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
277 call feedkeys("j^v2l\<C-G>", 'nx')
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
278
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
279 let bufnr = bufadd('Xdummy')
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
280 call bufload(bufnr)
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
281 call setbufline(bufnr, 1, ['abc', 'def'])
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
282 call deletebufline(bufnr, 1)
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
283
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
284 call feedkeys("x", 'nx')
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
285 call assert_equal(['foo', 'x'], getline(1, 2))
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
286
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
287 exe "bwipe! " .. bufnr
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
288 bwipe!
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
289 endfunc
8207581dd068 patch 8.2.5002: deletebufline() may change Visual selection
Bram Moolenaar <Bram@vim.org>
parents: 28948
diff changeset
290
31255
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
291 func Test_deletebufline_popup_window()
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
292 let popupID = popup_create('foo', {})
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
293 let bufnr = winbufnr(popupID)
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
294
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
295 " Check that deletebufline() brings us back to the same window.
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
296 new
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
297 let winid_before = win_getid()
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
298 call deletebufline(bufnr, 1, '$')
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
299 call assert_equal(winid_before, win_getid())
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
300 bwipe
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
301
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
302 call popup_close(popupID)
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
303 endfunc
87ff5e71d3c2 patch 9.0.0961: using deletebufline() may jump to another window
Bram Moolenaar <Bram@vim.org>
parents: 31164
diff changeset
304
29875
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
305 func Test_setbufline_startup_nofile()
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
306 let before =<< trim [CODE]
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
307 set shortmess+=F
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
308 file Xresult
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
309 set buftype=nofile
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
310 call setbufline('', 1, 'success')
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
311 [CODE]
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
312 let after =<< trim [CODE]
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
313 set buftype=
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
314 write
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
315 quit
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
316 [CODE]
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
317
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
318 if !RunVim(before, after, '--clean')
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
319 return
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
320 endif
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
321 call assert_equal(['success'], readfile('Xresult'))
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
322 call delete('Xresult')
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
323 endfunc
cb4d95b545f1 patch 9.0.0276: 'buftype' values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 28960
diff changeset
324
31012
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
325 " Test that setbufline(), appendbufline() and deletebufline() should fail and
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
326 " return 1 when "textlock" is active.
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
327 func Test_change_bufline_with_textlock()
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
328 new
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
329 inoremap <buffer> <expr> <F2> setbufline('', 1, '')
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
330 call assert_fails("normal a\<F2>", 'E565:')
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
331 call assert_equal('1', getline(1))
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
332 inoremap <buffer> <expr> <F2> appendbufline('', 1, '')
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
333 call assert_fails("normal a\<F2>", 'E565:')
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
334 call assert_equal('11', getline(1))
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
335 inoremap <buffer> <expr> <F2> deletebufline('', 1)
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
336 call assert_fails("normal a\<F2>", 'E565:')
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
337 call assert_equal('111', getline(1))
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
338 bwipe!
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
339 endfunc
4ba2890de10d patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents: 31004
diff changeset
340
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
341 " vim: shiftwidth=2 sts=2 expandtab