Mercurial > vim
comparison src/testdir/test_listener.vim @ 19044:af795b6a2624
patch 8.2.0082: when reusing a buffer listeners are not cleared
Commit: https://github.com/vim/vim/commit/f10997a1543eb0724d882da3678bacd44e647141
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 3 21:00:02 2020 +0100
patch 8.2.0082: when reusing a buffer listeners are not cleared
Problem: When reusing a buffer listeners are not cleared. (Axel Forsman)
Solution: Clear listeners when reusing a buffer. (closes https://github.com/vim/vim/issues/5431)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 03 Jan 2020 21:00:16 +0100 |
parents | 5da355d15b88 |
children | 36ec10251b2b |
comparison
equal
deleted
inserted
replaced
19043:9c3bd0bafcdc | 19044:af795b6a2624 |
---|---|
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 | 297 endfunc |
298 | |
299 func Test_listener_cleared_newbuf() | |
300 func Listener(bufnr, start, end, added, changes) | |
301 let g:gotCalled += 1 | |
302 endfunc | |
303 new | |
304 " check that listening works | |
305 let g:gotCalled = 0 | |
306 let lid = listener_add("Listener") | |
307 call feedkeys("axxx\<Esc>", 'xt') | |
308 call listener_flush(bufnr()) | |
309 call assert_equal(1, g:gotCalled) | |
310 %bwipe! | |
311 let bufnr = bufnr() | |
312 let b:testing = 123 | |
313 let lid = listener_add("Listener") | |
314 enew! | |
315 " check buffer is reused | |
316 call assert_equal(bufnr, bufnr()) | |
317 call assert_false(exists('b:testing')) | |
318 | |
319 " check that listening stops when reusing the buffer | |
320 let g:gotCalled = 0 | |
321 call feedkeys("axxx\<Esc>", 'xt') | |
322 call listener_flush(bufnr()) | |
323 call assert_equal(0, g:gotCalled) | |
324 unlet g:gotCalled | |
325 | |
326 bwipe! | |
327 delfunc Listener | |
328 endfunc |