@@ -70,13 +70,13 @@ func TriggerTheProblem()
70
70
exe " normal \<Esc> "
71
71
catch /^Vim\%((\a\+)\)\=:E315/
72
72
echom ' Snap! E315 error!'
73
- let g: msg= ' Snap! E315 error!'
73
+ let g: msg = ' Snap! E315 error!'
74
74
endtry
75
75
endfunc
76
76
77
77
func Test_visual_mode_reset ()
78
78
enew
79
- let g: msg= " Everything's fine."
79
+ let g: msg = " Everything's fine."
80
80
enew
81
81
setl buftype = nofile
82
82
call append (line (' $' ), ' Delete this line.' )
@@ -186,4 +186,59 @@ func Test_virtual_replace()
186
186
call assert_equal ([' AB......CDEFGHI.Jkl' ,
187
187
\ ' AB IJKLMNO QRst' ], getline (12 , 13 ))
188
188
enew !
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\n abcdefghi\n jk\t lmn\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\n A\n BCDEFGHIJ\n \t KL\n MNO\n PQR"
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
189
244
endfunc
0 commit comments