diff src/testdir/test_listener.vim @ 18025:d19caa851682 v8.1.2008

patch 8.1.2008: error for invalid range when using listener and undo Commit: https://github.com/vim/vim/commit/4544bd2f247425c9dd743c76618dd70f53c72538 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 8 15:27:21 2019 +0200 patch 8.1.2008: error for invalid range when using listener and undo Problem: Error for invalid range when using listener and undo. (Paul Jolly) Solution: Do not change the cursor before the lines are restored. (closes #4908)
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 Sep 2019 15:30:04 +0200
parents 2e53305f2239
children 5da355d15b88
line wrap: on
line diff
--- a/src/testdir/test_listener.vim
+++ b/src/testdir/test_listener.vim
@@ -234,7 +234,7 @@ func Test_listener_garbage_collect()
   new
   let id = listener_add(function('MyListener', [{}]), bufnr(''))
   call test_garbagecollect_now()
-  " must not crach caused by invalid memory access
+  " must not crash caused by invalid memory access
   normal ia
   call assert_true(v:true)
 
@@ -268,3 +268,25 @@ func Test_listener_caches_buffer_line()
   iunmap <CR>
   set nocindent
 endfunc
+
+" Verify the fix for issue #4908
+func Test_listener_undo_line_number()
+  function DoIt()
+    " NOP
+  endfunction
+  function EchoChanges(bufnr, start, end, added, changes)
+    call DoIt()
+  endfunction
+
+  new
+  let lid = listener_add("EchoChanges")
+  call setline(1, ['a', 'b', 'c'])
+  set undolevels&  " start new undo block
+  call feedkeys("ggcG\<Esc>", 'xt')
+  undo
+
+  bwipe!
+  delfunc DoIt
+  delfunc EchoChanges
+  call listener_remove(lid)
+endfunc