0
0
mirror of https://github.com/vim/vim.git synced 2025-09-04 21:33:48 -04:00

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.
This commit is contained in:
Bram Moolenaar 2020-03-25 21:13:46 +01:00
parent f66ca9f1df
commit a07e31af54
2 changed files with 27 additions and 0 deletions

View File

@ -296,6 +296,31 @@ func Test_listener_undo_line_number()
call listener_remove(lid)
endfunc
func Test_listener_undo_delete_all()
new
call setline(1, [1, 2, 3, 4])
let s:changes = []
func s:ExtendList(bufnr, start, end, added, changes)
call extend(s:changes, a:changes)
endfunc
let id = listener_add('s:ExtendList')
set undolevels& " start new undo block
normal! ggdG
undo
call listener_flush()
call assert_equal(2, s:changes->len())
" delete removes four lines, empty line remains
call assert_equal({'lnum': 1, 'end': 5, 'col': 1, 'added': -4}, s:changes[0])
" undo replaces empty line and adds 3 lines
call assert_equal({'lnum': 1, 'end': 2, 'col': 1, 'added': 3}, s:changes[1])
call listener_remove(id)
delfunc s:ExtendList
unlet s:changes
bwipe!
endfunc
func Test_listener_cleared_newbuf()
func Listener(bufnr, start, end, added, changes)
let g:gotCalled += 1

View File

@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
446,
/**/
445,
/**/