1
0
forked from aniani/vim

patch 9.1.1323: b:undo_ftplugin not executed when re-using buffer

Problem:  b:undo_ftplugin not executed when re-using buffer
          (archy3)
Solution: explicitly execute b:undo_ftplugin in buflist_new() when
          re-using the current buffer

fixes: #17113
closes: #17133

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-04-19 11:14:11 +02:00
parent 8167799651
commit baa8c90cc0
5 changed files with 49 additions and 2 deletions

View File

@@ -1131,6 +1131,34 @@ func Test_filetype_indent_off()
close
endfunc
func Test_undo_ftplugin_on_buffer_reuse()
filetype on
new
let b:undo_ftplugin = ":let g:var='exists'"
let g:bufnr = bufnr('%')
" no changes done to the buffer, so the buffer will be re-used
e $VIMRUNTIME/defaults.vim
call assert_equal(g:bufnr, bufnr('%'))
call assert_equal('exists', get(g:, 'var', 'fail'))
unlet! g:bufnr g:var
" try to wipe the buffer
enew
bw defaults.vim
let b:undo_ftplugin = ':bw'
call assert_fails(':e $VIMRUNTIME/defaults.vim', 'E937')
" try to split the window
enew
bw defaults.vim
let b:undo_ftplugin = ':sp $VIMRUNTIME/defaults.vim'
call assert_fails(':e $VIMRUNTIME/defaults.vim', 'E242')
bwipe!
filetype off
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""
" Tests for specific extensions and filetypes.
" Keep sorted.