comparison src/testdir/test_visual.vim @ 13402:338b15c63e2c v8.0.1575

patch 8.0.1575: crash when using virtual replace commit https://github.com/vim/vim/commit/63e82db6fc910b2d8f1cd018894e50e8b4448155 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 6 12:10:48 2018 +0100 patch 8.0.1575: crash when using virtual replace Problem: Crash when using virtual replace. Solution: Adjust orig_line_count. Add more tests. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Tue, 06 Mar 2018 12:15:05 +0100
parents aa658b33f25a
children 4e30f3f4cb78
comparison
equal deleted inserted replaced
13401:78cb47786195 13402:338b15c63e2c
68 '<,'>del _ 68 '<,'>del _
69 try 69 try
70 exe "normal \<Esc>" 70 exe "normal \<Esc>"
71 catch /^Vim\%((\a\+)\)\=:E315/ 71 catch /^Vim\%((\a\+)\)\=:E315/
72 echom 'Snap! E315 error!' 72 echom 'Snap! E315 error!'
73 let g:msg='Snap! E315 error!' 73 let g:msg = 'Snap! E315 error!'
74 endtry 74 endtry
75 endfunc 75 endfunc
76 76
77 func Test_visual_mode_reset() 77 func Test_visual_mode_reset()
78 enew 78 enew
79 let g:msg="Everything's fine." 79 let g:msg = "Everything's fine."
80 enew 80 enew
81 setl buftype=nofile 81 setl buftype=nofile
82 call append(line('$'), 'Delete this line.') 82 call append(line('$'), 'Delete this line.')
83 83
84 " NOTE: this has to be done by a call to a function because executing :del 84 " NOTE: this has to be done by a call to a function because executing :del
184 exe "normal 0gRAB......CDEFGHI.J\<Esc>o" 184 exe "normal 0gRAB......CDEFGHI.J\<Esc>o"
185 exe "normal iabcdefghijklmnopqrst\<Esc>0gRAB\tIJKLMNO\tQR" 185 exe "normal iabcdefghijklmnopqrst\<Esc>0gRAB\tIJKLMNO\tQR"
186 call assert_equal(['AB......CDEFGHI.Jkl', 186 call assert_equal(['AB......CDEFGHI.Jkl',
187 \ 'AB IJKLMNO QRst'], getline(12, 13)) 187 \ 'AB IJKLMNO QRst'], getline(12, 13))
188 enew! 188 enew!
189 endfunc 189 set noai bs&vim t_kD&vim t_kb&vim
190 endfunc
191
192 " Test Virtual replace mode.
193 func Test_virtual_replace2()
194 enew!
195 set bs=2
196 exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\<C-D>uvwxyz"
197 call cursor(1,1)
198 " Test 1: Test that del deletes the newline
199 exe "normal gR0\<del> 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR"
200 call assert_equal(['0 1',
201 \ 'A',
202 \ 'BCDEFGHIJ',
203 \ ' KL',
204 \ 'MNO',
205 \ 'PQR',
206 \ ], getline(1, 6))
207 " Test 2:
208 " a newline is not deleted, if no newline has been added in virtual replace mode
209 %d_
210 call setline(1, ['abcd', 'efgh', 'ijkl'])
211 call cursor(2,1)
212 exe "norm! gR1234\<cr>5\<bs>\<bs>\<bs>"
213 call assert_equal(['abcd',
214 \ '123h',
215 \ 'ijkl'], getline(1, '$'))
216 " Test 3:
217 " a newline is deleted, if a newline has been inserted before in virtual replace mode
218 %d_
219 call setline(1, ['abcd', 'efgh', 'ijkl'])
220 call cursor(2,1)
221 exe "norm! gR1234\<cr>\<cr>56\<bs>\<bs>\<bs>"
222 call assert_equal(['abcd',
223 \ '1234',
224 \ 'ijkl'], getline(1, '$'))
225 " Test 4:
226 " delete add a newline, delete it, add it again and check undo
227 %d_
228 call setline(1, ['abcd', 'efgh', 'ijkl'])
229 call cursor(2,1)
230 " break undo sequence explicitly
231 let &ul = &ul
232 exe "norm! gR1234\<cr>\<bs>\<del>56\<cr>"
233 let &ul = &ul
234 call assert_equal(['abcd',
235 \ '123456',
236 \ ''], getline(1, '$'))
237 norm! u
238 call assert_equal(['abcd',
239 \ 'efgh',
240 \ 'ijkl'], getline(1, '$'))
241 " clean up
242 %d_
243 set bs&vim
244 endfunc