comparison src/testdir/test_listener.vim @ 19779:f3162c3ed128 v8.2.0446

patch 8.2.0446: listener with undo of deleting all lines not tested Commit: https://github.com/vim/vim/commit/a07e31af545b91925362854a48c42fee16dd8c28 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 21:13:46 2020 +0100 patch 8.2.0446: listener with undo of deleting all lines not tested Problem: Listener with undo of deleting all lines not tested. Solution: Add a test.
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 21:15:04 +0100
parents 36ec10251b2b
children 2fb397573541
comparison
equal deleted inserted replaced
19778:20c46ad9e187 19779:f3162c3ed128
292 292
293 bwipe! 293 bwipe!
294 delfunc DoIt 294 delfunc DoIt
295 delfunc EchoChanges 295 delfunc EchoChanges
296 call listener_remove(lid) 296 call listener_remove(lid)
297 endfunc
298
299 func Test_listener_undo_delete_all()
300 new
301 call setline(1, [1, 2, 3, 4])
302 let s:changes = []
303 func s:ExtendList(bufnr, start, end, added, changes)
304 call extend(s:changes, a:changes)
305 endfunc
306 let id = listener_add('s:ExtendList')
307
308 set undolevels& " start new undo block
309 normal! ggdG
310 undo
311 call listener_flush()
312 call assert_equal(2, s:changes->len())
313 " delete removes four lines, empty line remains
314 call assert_equal({'lnum': 1, 'end': 5, 'col': 1, 'added': -4}, s:changes[0])
315 " undo replaces empty line and adds 3 lines
316 call assert_equal({'lnum': 1, 'end': 2, 'col': 1, 'added': 3}, s:changes[1])
317
318 call listener_remove(id)
319 delfunc s:ExtendList
320 unlet s:changes
321 bwipe!
297 endfunc 322 endfunc
298 323
299 func Test_listener_cleared_newbuf() 324 func Test_listener_cleared_newbuf()
300 func Listener(bufnr, start, end, added, changes) 325 func Listener(bufnr, start, end, added, changes)
301 let g:gotCalled += 1 326 let g:gotCalled += 1