mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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 #5431)
This commit is contained in:
parent
467c32bd72
commit
f10997a154
@ -979,6 +979,7 @@ free_buffer_stuff(
|
|||||||
hash_init(&buf->b_vars->dv_hashtab);
|
hash_init(&buf->b_vars->dv_hashtab);
|
||||||
init_changedtick(buf);
|
init_changedtick(buf);
|
||||||
CHANGEDTICK(buf) = tick;
|
CHANGEDTICK(buf) = tick;
|
||||||
|
remove_listeners(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
uc_clear(&buf->b_ucmds); // clear local user commands
|
uc_clear(&buf->b_ucmds); // clear local user commands
|
||||||
|
@ -295,3 +295,34 @@ func Test_listener_undo_line_number()
|
|||||||
delfunc EchoChanges
|
delfunc EchoChanges
|
||||||
call listener_remove(lid)
|
call listener_remove(lid)
|
||||||
endfunc
|
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
|
||||||
|
@ -742,6 +742,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
82,
|
||||||
/**/
|
/**/
|
||||||
81,
|
81,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user