From 888cdce3aa70c5800916b0d54ab40e8ac01d704a Mon Sep 17 00:00:00 2001 From: rover Date: Sat, 7 Jan 2017 22:56:51 +0800 Subject: vim-patch:7.4.2006 Problem: Crash when using tabnext in BufUnload autocmd. (Norio Takagi) Solution: First check that the current buffer is the right one. (Hirohito Higashi) https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a --- src/nvim/buffer.c | 18 ++++++++++-------- src/nvim/testdir/test_autocmd.vim | 18 ++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d9fdc80c60..fa41f0f382 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -406,9 +406,6 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) buf->b_nwindows = nwindows; buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); - if (win_valid_any_tab(win) && win->w_buffer == buf) { - win->w_buffer = NULL; // make sure we don't use the buffer now - } /* Autocommands may have deleted the buffer. */ if (!buf_valid(buf)) @@ -416,11 +413,6 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) if (aborting()) /* autocmds may abort script processing */ return; - /* Autocommands may have opened or closed windows for this buffer. - * Decrement the count for the close we do here. */ - if (buf->b_nwindows > 0) - --buf->b_nwindows; - /* * It's possible that autocommands change curbuf to the one being deleted. * This might cause the previous curbuf to be deleted unexpectedly. But @@ -431,6 +423,16 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) if (buf == curbuf && !is_curbuf) return; + if (win_valid_any_tab(win) && win->w_buffer == buf) { + win->w_buffer = NULL; // make sure we don't use the buffer now + } + + // Autocommands may have opened or closed windows for this buffer. + // Decrement the count for the close we do here. + if (buf->b_nwindows > 0) { + buf->b_nwindows--; + } + /* Change directories when the 'acd' option is set. */ do_autochdir(); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 5675697dc4..8ead589871 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -64,6 +64,24 @@ function Test_bufunload() augroup! test_bufunload_group endfunc +" SEGV occurs in older versions. (At least 7.4.2005 or older) +function Test_autocmd_bufunload_with_tabnext() + tabedit + tabfirst + + augroup test_autocmd_bufunload_with_tabnext_group + autocmd! + autocmd BufUnload tabnext + augroup END + + quit + call assert_equal(2, tabpagenr('$')) + + augroup! test_autocmd_bufunload_with_tabnext_group + tablast + quit +endfunc + func s:AddAnAutocmd() augroup vimBarTest au BufReadCmd * echo 'hello' diff --git a/src/nvim/version.c b/src/nvim/version.c index 19062be730..f644b9f39b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -434,7 +434,7 @@ static int included_patches[] = { // 2009, // 2008, 2007, - // 2006, + 2006, 2005, // 2004 NA // 2003 NA -- cgit From c2344f3d31fe6a006027dbf88873ee0916b73028 Mon Sep 17 00:00:00 2001 From: rover Date: Sun, 8 Jan 2017 21:05:41 +0800 Subject: vim-patch:7.4.2075 Problem: No autocommand event to initialize a window or tab page. Solution: Add WinNew and TabNew events. (partly by Felipe Morales) https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8 --- src/nvim/auevents.lua | 1 + src/nvim/testdir/test_autocmd.vim | 30 ++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- src/nvim/window.c | 32 ++++++++++++++++++++------------ 4 files changed, 52 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua index 8d891effae..b405928577 100644 --- a/src/nvim/auevents.lua +++ b/src/nvim/auevents.lua @@ -89,6 +89,7 @@ return { 'VimLeave', -- before exiting Vim 'VimLeavePre', -- before exiting Vim and writing ShaDa file 'VimResized', -- after Vim window was resized + 'WinNew', -- when entering a new window 'WinEnter', -- after entering a window 'WinLeave', -- before leaving a window }, diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 8ead589871..5777ebcddc 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -82,6 +82,36 @@ function Test_autocmd_bufunload_with_tabnext() quit endfunc +func Test_win_tab_autocmd() + let g:record = [] + + augroup testing + au WinNew * call add(g:record, 'WinNew') + au WinEnter * call add(g:record, 'WinEnter') + au WinLeave * call add(g:record, 'WinLeave') + au TabNew * call add(g:record, 'TabNew') + au TabEnter * call add(g:record, 'TabEnter') + au TabLeave * call add(g:record, 'TabLeave') + augroup END + + split + tabnew + close + close + + call assert_equal([ + \ 'WinLeave', 'WinNew', 'WinEnter', + \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter', + \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', + \ 'WinLeave', 'WinEnter' + \ ], g:record) + + augroup testing + au! + augroup END + unlet g:record +endfunc + func s:AddAnAutocmd() augroup vimBarTest au BufReadCmd * echo 'hello' diff --git a/src/nvim/version.c b/src/nvim/version.c index f644b9f39b..f1ea69c30e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -365,7 +365,7 @@ static int included_patches[] = { // 2078 NA // 2077, // 2076, - // 2075, + 2075, // 2074, // 2073 NA // 2072, diff --git a/src/nvim/window.c b/src/nvim/window.c index 00229ccca9..301dc93026 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -973,11 +973,12 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) /* * make the new window the current window */ - win_enter(wp, false); - if (flags & WSP_VERT) + win_enter_ext(wp, false, false, true, true, true); + if (flags & WSP_VERT) { p_wiw = i; - else + } else { p_wh = i; + } return OK; } @@ -2014,10 +2015,11 @@ int win_close(win_T *win, int free_buf) } if (close_curwin) { - win_enter_ext(wp, false, TRUE, TRUE, TRUE); - if (other_buffer) - /* careful: after this wp and win may be invalid! */ - apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); + win_enter_ext(wp, false, true, false, true, true); + if (other_buffer) { + // careful: after this wp and win may be invalid! + apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf); + } } /* @@ -3045,8 +3047,9 @@ int win_new_tabpage(int after, char_u *filename) redraw_all_later(CLEAR); - apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf); + apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); + apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf); return OK; @@ -3204,8 +3207,8 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au /* We would like doing the TabEnter event first, but we don't have a * valid current window yet, which may break some commands. * This triggers autocommands, thus may make "tp" invalid. */ - win_enter_ext(tp->tp_curwin, false, TRUE, - trigger_enter_autocmds, trigger_leave_autocmds); + win_enter_ext(tp->tp_curwin, false, true, false, + trigger_enter_autocmds, trigger_leave_autocmds); prevwin = next_prevwin; last_status(FALSE); /* status line may appear or disappear */ @@ -3546,7 +3549,7 @@ end: */ void win_enter(win_T *wp, bool undo_sync) { - win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE); + win_enter_ext(wp, undo_sync, false, false, true, true); } /* @@ -3554,7 +3557,9 @@ void win_enter(win_T *wp, bool undo_sync) * Can be called with "curwin_invalid" TRUE, which means that curwin has just * been closed and isn't valid. */ -static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int trigger_enter_autocmds, int trigger_leave_autocmds) +static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, + int trigger_new_autocmds, int trigger_enter_autocmds, + int trigger_leave_autocmds) { int other_buffer = FALSE; @@ -3630,6 +3635,9 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri shorten_fnames(TRUE); } + if (trigger_new_autocmds) { + apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf); + } if (trigger_enter_autocmds) { apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); if (other_buffer) -- cgit From f5d06c52a24b512fe555a548360a8393e70007a3 Mon Sep 17 00:00:00 2001 From: rover Date: Sun, 8 Jan 2017 23:12:52 +0800 Subject: vim-patch:7.4.2077 Problem: Cannot update 'tabline' when a tab was closed. Solution: Add the TabClosed autocmd event. (partly by Felipe Morales) https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2 --- src/nvim/testdir/test_autocmd.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 5777ebcddc..b9d5cfe27b 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -90,6 +90,7 @@ func Test_win_tab_autocmd() au WinEnter * call add(g:record, 'WinEnter') au WinLeave * call add(g:record, 'WinLeave') au TabNew * call add(g:record, 'TabNew') + au TabClosed * call add(g:record, 'TabClosed') au TabEnter * call add(g:record, 'TabEnter') au TabLeave * call add(g:record, 'TabLeave') augroup END @@ -102,10 +103,21 @@ func Test_win_tab_autocmd() call assert_equal([ \ 'WinLeave', 'WinNew', 'WinEnter', \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter', - \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', + \ 'WinLeave', 'TabLeave', 'TabClosed', 'WinEnter', 'TabEnter', \ 'WinLeave', 'WinEnter' \ ], g:record) + let g:record = [] + tabnew somefile + tabnext + bwipe somefile + + call assert_equal([ + \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter', + \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter', + \ 'TabClosed' + \ ], g:record) + augroup testing au! augroup END -- cgit From 7486e7586d94c85f04e50ac7429acedc80f9da2f Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 9 Jan 2017 08:41:45 +0800 Subject: vim-patch:7.4.2117 Problem: Deleting an augroup that still has autocmds does not give a warning. The next defined augroup takes its place. Solution: Give a warning and prevent the index being used for another group name. https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f --- src/nvim/fileio.c | 75 ++++++++++++++++++++++++++++++--------- src/nvim/testdir/test_autocmd.vim | 17 +++++++++ src/nvim/version.c | 2 +- 3 files changed, 76 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index bbfa56dfbf..3f82b4ee97 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5366,6 +5366,7 @@ static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */ */ static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL}; #define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i]) +static char_u *deleted_augroup = NULL; /* * The ID of the current group. Group 0 is the default one. @@ -5399,10 +5400,11 @@ static void show_autocmd(AutoPat *ap, event_T event) return; if (event != last_event || ap->group != last_group) { if (ap->group != AUGROUP_DEFAULT) { - if (AUGROUP_NAME(ap->group) == NULL) - msg_puts_attr((char_u *)_("--Deleted--"), hl_attr(HLF_E)); - else + if (AUGROUP_NAME(ap->group) == NULL) { + msg_puts_attr(deleted_augroup, hl_attr(HLF_E)); + } else { msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T)); + } msg_puts((char_u *)" "); } msg_puts_attr(event_nr2name(event), hl_attr(HLF_T)); @@ -5568,11 +5570,34 @@ static void au_del_group(char_u *name) int i; i = au_find_group(name); - if (i == AUGROUP_ERROR) /* the group doesn't exist */ + if (i == AUGROUP_ERROR) { // the group doesn't exist EMSG2(_("E367: No such group: \"%s\""), name); - else { + } else { + event_T event; + AutoPat *ap; + int in_use = false; + + for (event = (event_T)0; (int)event < (int)NUM_EVENTS; + event = (event_T)((int)event + 1)) { + for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) { + if (ap->group == i) { + give_warning((char_u *) + _("W19: Deleting augroup that is still in use"), true); + in_use = true; + event = NUM_EVENTS; + break; + } + } + } xfree(AUGROUP_NAME(i)); - AUGROUP_NAME(i) = NULL; + if (in_use) { + if (deleted_augroup == NULL) { + deleted_augroup = (char_u *)_("--Deleted--"); + } + AUGROUP_NAME(i) = deleted_augroup; + } else { + AUGROUP_NAME(i) = NULL; + } } } @@ -5584,8 +5609,9 @@ static void au_del_group(char_u *name) static int au_find_group(const char_u *name) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - for (int i = 0; i < augroups.ga_len; ++i) { - if (AUGROUP_NAME(i) != NULL && STRCMP(AUGROUP_NAME(i), name) == 0) { + for (int i = 0; i < augroups.ga_len; i++) { + if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != deleted_augroup + && STRCMP(AUGROUP_NAME(i), name) == 0) { return i; } } @@ -5633,10 +5659,21 @@ void do_augroup(char_u *arg, int del_group) #if defined(EXITFREE) void free_all_autocmds(void) { + int i; + char_u *s; + for (current_augroup = -1; current_augroup < augroups.ga_len; - ++current_augroup) - do_autocmd((char_u *)"", TRUE); - ga_clear_strings(&augroups); + current_augroup++) { + do_autocmd((char_u *)"", true); + } + + for (i = 0; i < augroups.ga_len; i++) { + s = ((char_u **)(augroups.ga_data))[i]; + if (s != deleted_augroup) { + xfree(s); + } + } + ga_clear(&augroups); } #endif @@ -7098,9 +7135,11 @@ char_u *get_augroup_name(expand_T *xp, int idx) return (char_u *)"END"; if (idx >= augroups.ga_len) /* end of list */ return NULL; - if (AUGROUP_NAME(idx) == NULL) /* skip deleted entries */ + if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == deleted_augroup) { + // skip deleted entries return (char_u *)""; - return AUGROUP_NAME(idx); /* return a name */ + } + return AUGROUP_NAME(idx); // return a name } static int include_groups = FALSE; @@ -7157,10 +7196,12 @@ set_context_in_autocmd ( */ char_u *get_event_name(expand_T *xp, int idx) { - if (idx < augroups.ga_len) { /* First list group names, if wanted */ - if (!include_groups || AUGROUP_NAME(idx) == NULL) - return (char_u *)""; /* skip deleted entries */ - return AUGROUP_NAME(idx); /* return a name */ + if (idx < augroups.ga_len) { // First list group names, if wanted + if (!include_groups || AUGROUP_NAME(idx) == NULL + || AUGROUP_NAME(idx) == deleted_augroup) { + return (char_u *)""; // skip deleted entries + } + return AUGROUP_NAME(idx); // return a name } return (char_u *)event_names[idx - augroups.ga_len].name; } diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index b9d5cfe27b..d856d3296a 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -151,3 +151,20 @@ func Test_early_bar() au! vimBarTest|echo 'hello' call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) endfunc + +func Test_augroup_warning() + augroup TheWarning + au VimEnter * echo 'entering' + augroup END + call assert_true(match(execute('au VimEnter'), "TheWarning.*VimEnter") >= 0) + redir => res + augroup! TheWarning + redir END + call assert_true(match(res, "W19:") >= 0) + call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0) + + " check "Another" does not take the pace of the deleted entry + augroup Another + augroup END + call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0) +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index f1ea69c30e..260e4c743e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -323,7 +323,7 @@ static int included_patches[] = { // 2120, // 2119, // 2118 NA - // 2117, + 2117, // 2116 NA // 2115 NA // 2114 NA -- cgit From 6f285226a9cc0e24bcb77a3213035cd26170ddb4 Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 9 Jan 2017 11:00:56 +0800 Subject: vim-patch:7.4.2300 Problem: Get warning for deleting autocommand group when the autocommand using the group is scheduled for deletion. (Pavol Juhas) Solution: Check for deleted autocommand. https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1 --- src/nvim/fileio.c | 2 +- src/nvim/testdir/test_autocmd.vim | 15 +++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 3f82b4ee97..31db8e2341 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5580,7 +5580,7 @@ static void au_del_group(char_u *name) for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) { for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) { - if (ap->group == i) { + if (ap->group == i && ap->pat != NULL) { give_warning((char_u *) _("W19: Deleting augroup that is still in use"), true); in_use = true; diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index d856d3296a..6db3bf76d3 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -152,6 +152,11 @@ func Test_early_bar() call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) endfunc +func RemoveGroup() + autocmd! StartOK + augroup! StartOK +endfunc + func Test_augroup_warning() augroup TheWarning au VimEnter * echo 'entering' @@ -167,4 +172,14 @@ func Test_augroup_warning() augroup Another augroup END call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0) + + " no warning for postpone aucmd delete + augroup StartOK + au VimEnter * call RemoveGroup() + augroup END + call assert_true(match(execute('au VimEnter'), "StartOK.*VimEnter") >= 0) + redir => res + doautocmd VimEnter + redir END + call assert_true(match(res, "W19:") < 0) endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 260e4c743e..93d72a9b0a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -140,7 +140,7 @@ static int included_patches[] = { // 2303, // 2302 NA // 2301 NA - // 2300, + 2300, // 2299, // 2298 NA // 2297 NA -- cgit From f8f04350bd07bc0f3e6f618bc6c8ff4d7ce3d5ac Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 9 Jan 2017 12:01:50 +0800 Subject: vim-patch:7.4.2313 Problem: Crash when deleting an augroup and listing an autocommand. (Dominique Pelle) Solution: Make sure deleted_augroup is valid. https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c --- src/nvim/fileio.c | 24 +++++++++++++++--------- src/nvim/testdir/test_autocmd.vim | 9 +++++++++ src/nvim/version.c | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 31db8e2341..dbe4a144df 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5366,6 +5366,7 @@ static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */ */ static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL}; #define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i]) +// use get_deleted_augroup() to get this static char_u *deleted_augroup = NULL; /* @@ -5381,6 +5382,14 @@ static event_T last_event; static int last_group; static int autocmd_blocked = 0; /* block all autocmds */ +static char_u *get_deleted_augroup(void) +{ + if (deleted_augroup == NULL) { + deleted_augroup = (char_u *)_("--Deleted--"); + } + return deleted_augroup; +} + /* * Show the autocommands for one AutoPat. */ @@ -5401,7 +5410,7 @@ static void show_autocmd(AutoPat *ap, event_T event) if (event != last_event || ap->group != last_group) { if (ap->group != AUGROUP_DEFAULT) { if (AUGROUP_NAME(ap->group) == NULL) { - msg_puts_attr(deleted_augroup, hl_attr(HLF_E)); + msg_puts_attr(get_deleted_augroup(), hl_attr(HLF_E)); } else { msg_puts_attr(AUGROUP_NAME(ap->group), hl_attr(HLF_T)); } @@ -5591,10 +5600,7 @@ static void au_del_group(char_u *name) } xfree(AUGROUP_NAME(i)); if (in_use) { - if (deleted_augroup == NULL) { - deleted_augroup = (char_u *)_("--Deleted--"); - } - AUGROUP_NAME(i) = deleted_augroup; + AUGROUP_NAME(i) = get_deleted_augroup(); } else { AUGROUP_NAME(i) = NULL; } @@ -5610,7 +5616,7 @@ static int au_find_group(const char_u *name) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { for (int i = 0; i < augroups.ga_len; i++) { - if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != deleted_augroup + if (AUGROUP_NAME(i) != NULL && AUGROUP_NAME(i) != get_deleted_augroup() && STRCMP(AUGROUP_NAME(i), name) == 0) { return i; } @@ -5669,7 +5675,7 @@ void free_all_autocmds(void) for (i = 0; i < augroups.ga_len; i++) { s = ((char_u **)(augroups.ga_data))[i]; - if (s != deleted_augroup) { + if (s != get_deleted_augroup()) { xfree(s); } } @@ -7135,7 +7141,7 @@ char_u *get_augroup_name(expand_T *xp, int idx) return (char_u *)"END"; if (idx >= augroups.ga_len) /* end of list */ return NULL; - if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == deleted_augroup) { + if (AUGROUP_NAME(idx) == NULL || AUGROUP_NAME(idx) == get_deleted_augroup()) { // skip deleted entries return (char_u *)""; } @@ -7198,7 +7204,7 @@ char_u *get_event_name(expand_T *xp, int idx) { if (idx < augroups.ga_len) { // First list group names, if wanted if (!include_groups || AUGROUP_NAME(idx) == NULL - || AUGROUP_NAME(idx) == deleted_augroup) { + || AUGROUP_NAME(idx) == get_deleted_augroup()) { return (char_u *)""; // skip deleted entries } return AUGROUP_NAME(idx); // return a name diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 6db3bf76d3..7d786c88cf 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -183,3 +183,12 @@ func Test_augroup_warning() redir END call assert_true(match(res, "W19:") < 0) endfunc + +func Test_augroup_deleted() + " This caused a crash + augroup x + augroup! x + au VimEnter * echo + au VimEnter +endfunc + diff --git a/src/nvim/version.c b/src/nvim/version.c index 93d72a9b0a..2d5f2437de 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -127,7 +127,7 @@ static int included_patches[] = { // 2316 NA // 2315, // 2314, - // 2313, + 2313, 2312, // 2311 NA // 2310 NA -- cgit From a584375e9ffa3804077ec8cedfe8b090c1c11f7a Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 9 Jan 2017 12:15:10 +0800 Subject: vim-patch:7.4.2314 Problem: No error when deleting an augroup while it's the current one. Solution: Disallow deleting an augroup when it's the current one. https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8 --- src/nvim/fileio.c | 2 ++ src/nvim/testdir/test_autocmd.vim | 10 +++++++--- src/nvim/version.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index dbe4a144df..e10f7fd2a2 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5581,6 +5581,8 @@ static void au_del_group(char_u *name) i = au_find_group(name); if (i == AUGROUP_ERROR) { // the group doesn't exist EMSG2(_("E367: No such group: \"%s\""), name); + } else if (i == current_augroup) { + EMSG(_("E936: Cannot delete the current group")); } else { event_T event; AutoPat *ap; diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 7d786c88cf..f05a55f1aa 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -182,13 +182,17 @@ func Test_augroup_warning() doautocmd VimEnter redir END call assert_true(match(res, "W19:") < 0) + au! VimEnter endfunc func Test_augroup_deleted() - " This caused a crash + " This caused a crash before E936 was introduced augroup x + call assert_fails('augroup! x', 'E936:') + au VimEnter * echo + augroup end augroup! x - au VimEnter * echo - au VimEnter + call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0) + au! VimEnter endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 2d5f2437de..f34473098c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -126,7 +126,7 @@ static int included_patches[] = { // 2317, // 2316 NA // 2315, - // 2314, + 2314, 2313, 2312, // 2311 NA -- cgit From 2b56cf099a8f383e74496ff48810c8029d3c1ba5 Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 9 Jan 2017 13:06:24 +0800 Subject: fix test failure --- src/nvim/window.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 301dc93026..89228e1b0f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1719,6 +1719,7 @@ close_windows ( { tabpage_T *tp, *nexttp; int h = tabline_height(); + int count = tabpage_index(NULL); ++RedrawingDisabled; @@ -1755,9 +1756,14 @@ close_windows ( --RedrawingDisabled; - redraw_tabline = TRUE; - if (h != tabline_height()) + if (count != tabpage_index(NULL)) { + apply_autocmds(EVENT_TABCLOSED, NULL, NULL, false, curbuf); + } + + redraw_tabline = true; + if (h != tabline_height()) { shell_new_rows(); + } } /// Check that current window is the last one. -- cgit