Patch 8.2.0082
Problem:    When reusing a buffer listeners are not cleared. (Axel Forsman)
Solution:   Clear listeners when reusing a buffer. (closes #5431)
Files:      src/testdir/test_listener.vim, src/buffer.c


*** ../vim-8.2.0081/src/testdir/test_listener.vim       2019-10-24 
20:05:31.000000000 +0200
--- src/testdir/test_listener.vim       2020-01-03 20:18:07.063813933 +0100
***************
*** 295,297 ****
--- 295,328 ----
    delfunc EchoChanges
    call listener_remove(lid)
  endfunc
+ 
+ func Test_listener_cleared_newbuf()
+   func Listener(bufnr, start, end, added, changes)
+     let g:gotCalled += 1
+   endfunc
+   new
+   " check that listening works
+   let g:gotCalled = 0
+   let lid = listener_add("Listener")
+   call feedkeys("axxx\<Esc>", 'xt')
+   call listener_flush(bufnr())
+   call assert_equal(1, g:gotCalled)
+   %bwipe!
+   let bufnr = bufnr()
+   let b:testing = 123
+   let lid = listener_add("Listener")
+   enew!
+   " check buffer is reused
+   call assert_equal(bufnr, bufnr())
+   call assert_false(exists('b:testing'))
+ 
+   " check that listening stops when reusing the buffer
+   let g:gotCalled = 0
+   call feedkeys("axxx\<Esc>", 'xt')
+   call listener_flush(bufnr())
+   call assert_equal(0, g:gotCalled)
+   unlet g:gotCalled
+ 
+   bwipe!
+   delfunc Listener
+ endfunc
*** ../vim-8.2.0081/src/buffer.c        2019-12-30 21:58:58.359667037 +0100
--- src/buffer.c        2020-01-03 20:21:19.075172081 +0100
***************
*** 979,984 ****
--- 979,985 ----
        hash_init(&buf->b_vars->dv_hashtab);
        init_changedtick(buf);
        CHANGEDTICK(buf) = tick;
+       remove_listeners(buf);
      }
  #endif
      uc_clear(&buf->b_ucmds);          // clear local user commands
*** ../vim-8.2.0081/src/version.c       2020-01-03 19:12:05.108214944 +0100
--- src/version.c       2020-01-03 20:17:01.044032346 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     82,
  /**/

-- 
Compilation process failed successfully.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001032000.003K0W1R023632%40masaka.moolenaar.net.

Raspunde prin e-mail lui