]> granicus.if.org Git - vim/commitdiff
patch 8.2.0446: listener with undo of deleting all lines not tested v8.2.0446
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Mar 2020 20:13:46 +0000 (21:13 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Mar 2020 20:13:46 +0000 (21:13 +0100)
Problem:    Listener with undo of deleting all lines not tested.
Solution:   Add a test.

src/testdir/test_listener.vim
src/version.c

index 9c9ba7fe43dd8e33db42485032a2efa4d22f5760..03724206411fe55deeb57cda7552f25ab53df994 100644 (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
index f99097def9028c192505ee2df7e732c278c2ca5e..6b5e252a92c11c92adf230020c2c8d14d190505d 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    446,
 /**/
     445,
 /**/