mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +00:00
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: vim/vim#17113
closes: vim/vim#17133
baa8c90cc0
Cherry-pick test_filetype.vim changes from patch 9.1.1325.
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -129,6 +129,18 @@ typedef enum {
|
||||
kBffInitChangedtick = 2,
|
||||
} BufFreeFlags;
|
||||
|
||||
static void trigger_undo_ftplugin(buf_T *buf, win_T *win)
|
||||
{
|
||||
window_layout_lock();
|
||||
buf->b_locked++;
|
||||
win->w_locked = true;
|
||||
// b:undo_ftplugin may be set, undo it
|
||||
do_cmdline_cmd("if exists('b:undo_ftplugin') | exe b:undo_ftplugin | endif");
|
||||
buf->b_locked--;
|
||||
win->w_locked = false;
|
||||
window_layout_unlock();
|
||||
}
|
||||
|
||||
/// Calculate the percentage that `part` is of the `whole`.
|
||||
int calc_percentage(int64_t part, int64_t whole)
|
||||
{
|
||||
@@ -1945,6 +1957,7 @@ buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags)
|
||||
assert(curbuf != NULL);
|
||||
buf = curbuf;
|
||||
set_bufref(&bufref, buf);
|
||||
trigger_undo_ftplugin(buf, curwin);
|
||||
// It's like this buffer is deleted. Watch out for autocommands that
|
||||
// change curbuf! If that happens, allocate a new buffer anyway.
|
||||
buf_freeall(buf, BFA_WIPE | BFA_DEL);
|
||||
|
||||
Reference in New Issue
Block a user