From 9ca90fdb9fda017962129125ea886fbf07345f62 Mon Sep 17 00:00:00 2001 From: Grzegorz Milka Date: Tue, 18 Oct 2016 21:04:57 +0200 Subject: [PATCH 1/6] vim-patch:7.4.2212 Problem: Mark " is not set when closing a window in another tab. (Guraga) Solution: Check all tabs for the window to be valid. (based on patch by Hirohito Higashi, closes vim/vim#974) https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a --- src/nvim/buffer.c | 4 ++-- src/nvim/version.c | 2 +- src/nvim/window.c | 17 +++++++++++++++++ test/functional/shada/marks_spec.lua | 12 ++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 5fb011885e..176967ad2a 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -323,7 +323,7 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) wipe_buf = true; } - if (win_valid(win)) { + if (win_valid_any_tab(win)) { /* Set b_last_cursor when closing the last window for the buffer. * Remember the last cursor position and window options of the buffer. * This used to be only for the current window, but then options like @@ -402,7 +402,7 @@ 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(win) && win->w_buffer == buf) { + if (win_valid_any_tab(win) && win->w_buffer == buf) { win->w_buffer = NULL; // make sure we don't use the buffer now } diff --git a/src/nvim/version.c b/src/nvim/version.c index 2dfe5d3248..1a72238394 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -229,7 +229,7 @@ static int included_patches[] = { // 2215, // 2214 NA 2213, - // 2212, + 2212, // 2211 NA // 2210 NA // 2209, diff --git a/src/nvim/window.c b/src/nvim/window.c index 03a2e9a842..c4e48a9732 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1065,6 +1065,23 @@ bool win_valid(win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT return false; } +/// Check if "win" is a pointer to an existing window in any tabpage. +/// +/// @param win window to check +bool win_valid_any_tab(win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + if (win == NULL) { + return false; + } + + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (wp == win) { + return true; + } + } + return false; +} + /* * Return the number of windows. */ diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index 646b0b692e..b743c3a4b7 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -102,6 +102,18 @@ describe('ShaDa support code', function() eq(2, nvim_current_line()) end) + it('is able to dump and read back mark " from a closed tab', function() + nvim_command('edit ' .. testfilename) + nvim_command('edit ' .. testfilename_2) + nvim_command('2') + nvim_command('q!') + nvim_command('qall') + reset() + nvim_command('edit ' .. testfilename_2) + nvim_command('normal! `"') + eq(2, nvim_current_line()) + end) + it('is able to populate v:oldfiles', function() nvim_command('edit ' .. testfilename) local tf_full = curbufmeths.get_name() From d7b942b54e4bae5510549ceffb3280e89871cff5 Mon Sep 17 00:00:00 2001 From: Grzegorz Milka Date: Sun, 23 Oct 2016 00:00:47 +0200 Subject: [PATCH 2/6] vim-patch:7.4.2237 Problem: Can't use "." and "$" with ":tab". Solution: Support a range for ":tab". (Hirohito Higashi) https://github.com/vim/vim/commit/9b7f8ce9eb3cb704f8cc14ab659bf86b1d6dc13c --- runtime/doc/tabpage.txt | 23 ++++++++++++++-------- src/nvim/ex_docmd.c | 21 ++++++++++++-------- src/nvim/testdir/test_tabpage.vim | 32 +++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index 70e6953211..4ab5b3c759 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -83,14 +83,21 @@ In the GUI tab pages line you can use the right mouse button to open menu. Execute {cmd} and when it opens a new window open a new tab page instead. Doesn't work for |:diffsplit|, |:diffpatch|, |:execute| and |:normal|. - When [count] is omitted the tab page appears after the current - one. - When [count] is specified the new tab page comes after tab - page [count]. Use ":0tab cmd" to get the new tab page as the - first one. + If [count] is given the new tab page appears after the tab + page [count] otherwise the new tab page will appear after the + current one. Examples: > - :tab split " opens current buffer in new tab page - :tab help gt " opens tab page with help for "gt" + :tab split " opens current buffer in new tab page + :tab help gt " opens tab page with help for "gt" + :.tab help gt " as above + :+tab help " opens tab page with help after the next + " tab page + :-tab help " opens tab page with help before the + " current one + :0tab help " opens tab page with help before the + " first one + :$tab help " opens tab page with help after the last + " one CTRL-W gf Open a new tab page and edit the file name under the cursor. See |CTRL-W_gf|. @@ -140,7 +147,7 @@ something else. :{count}tabo[nly][!] Close all tab pages except the {count}th one. > - :.tabonly " one + :.tabonly " as above :-tabonly " close all tab pages except the previous one :+tabonly " close all tab pages except the next one :1tabonly " close all tab pages except the first one diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9f83688e1e..cbe4d19d2c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1302,8 +1302,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, * 2. Handle command modifiers. */ p = ea.cmd; - if (ascii_isdigit(*ea.cmd)) - p = skipwhite(skipdigits(ea.cmd)); + p = skip_range(ea.cmd, NULL); switch (*p) { /* When adding an entry, also modify cmd_exists(). */ case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) @@ -1406,12 +1405,18 @@ static char_u * do_one_cmd(char_u **cmdlinep, continue; case 't': if (checkforcmd(&p, "tab", 3)) { - if (ascii_isdigit(*ea.cmd)) - cmdmod.tab = atoi((char *)ea.cmd) + 1; - else - cmdmod.tab = tabpage_index(curtab) + 1; - ea.cmd = p; - continue; + long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, ea.skip, false); + if (tabnr == MAXLNUM) { + cmdmod.tab = tabpage_index(curtab) + 1; + } else { + if (tabnr < 0 || tabnr > LAST_TAB_NR) { + errormsg = (char_u *)_(e_invrange); + goto doend; + } + cmdmod.tab = tabnr + 1; + } + ea.cmd = p; + continue; } if (!checkforcmd(&ea.cmd, "topleft", 2)) break; diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index e6b85d6e14..f1c41e967b 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -186,4 +186,36 @@ function Test_tabpage_with_autocmd() bw! endfunction +function Test_tabpage_with_tab_modifier() + for n in range(4) + tabedit + endfor + + function s:check_tab(pre_nr, cmd, post_nr) + exec 'tabnext ' . a:pre_nr + exec a:cmd + call assert_equal(a:post_nr, tabpagenr()) + call assert_equal('help', &filetype) + helpclose + endfunc + + call s:check_tab(1, 'tab help', 2) + call s:check_tab(1, '3tab help', 4) + call s:check_tab(1, '.tab help', 2) + call s:check_tab(1, '.+1tab help', 3) + call s:check_tab(1, '0tab help', 1) + call s:check_tab(2, '+tab help', 4) + call s:check_tab(2, '+2tab help', 5) + call s:check_tab(4, '-tab help', 4) + call s:check_tab(4, '-2tab help', 3) + call s:check_tab(3, '$tab help', 6) + call assert_fails('99tab help', 'E16:') + call assert_fails('+99tab help', 'E16:') + call assert_fails('-99tab help', 'E16:') + + delfunction s:check_tab + tabonly! + bw! +endfunction + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 1a72238394..fffd8e79de 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -204,7 +204,7 @@ static int included_patches[] = { // 2240, // 2239, // 2238 NA - // 2237, + 2237, // 2236, // 2235, // 2234 NA From c5c8a821341b71ae29786c97df7930a9581f7ab7 Mon Sep 17 00:00:00 2001 From: Grzegorz Milka Date: Sun, 23 Oct 2016 00:25:16 +0200 Subject: [PATCH 3/6] vim-patch:7.4.2309 Problem: Crash when doing tabnext in a BufUnload autocmd. (Dominique Pelle) Solution: When detecting that the tab page changed, don't just abort but delete the window where w_buffer is NULL. https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743 --- src/nvim/testdir/test_tabpage.vim | 14 ++++++++++++++ src/nvim/version.c | 2 +- src/nvim/window.c | 32 +++++++++++++++++++++---------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index f1c41e967b..7bdea0b186 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -218,4 +218,18 @@ function Test_tabpage_with_tab_modifier() bw! endfunction +func Test_tabnext_on_buf_unload() + " This once caused a crash + new + tabedit + tabfirst + au BufUnload tabnext + q + + while tabpagenr('$') > 1 + quit + endwhile +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index fffd8e79de..f0f6f6a3cb 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -132,7 +132,7 @@ static int included_patches[] = { // 2312, // 2311, // 2310 NA - // 2309, + 2309, // 2308 NA // 2307, // 2306, diff --git a/src/nvim/window.c b/src/nvim/window.c index c4e48a9732..2fb1fbede9 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1935,7 +1935,7 @@ int win_close(win_T *win, int free_buf) if (win->w_buffer != NULL) { win->w_closing = true; close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, true); - if (win_valid(win)) { + if (win_valid_any_tab(win)) { win->w_closing = false; } @@ -1955,11 +1955,19 @@ int win_close(win_T *win, int free_buf) curwin->w_buffer = curbuf; getout(0); } - /* Autocommands may have closed the window already, or closed the only - * other window or moved to another tab page. */ - else if (!win_valid(win) || last_window() || curtab != prev_curtab - || close_last_window_tabpage(win, free_buf, prev_curtab)) + // Autocommands may have moved to another tab page. + if (curtab != prev_curtab && win_valid_any_tab(win) + && win->w_buffer == NULL) { + // Need to close the window anyway, since the buffer is NULL. + win_close_othertab(win, false, prev_curtab); return FAIL; + } + // Autocommands may have closed the window already, or closed the only + // other window or moved to another tab page. + if (!win_valid(win) || last_window() + || close_last_window_tabpage(win, free_buf, prev_curtab)) { + return FAIL; + } // let terminal buffers know that this window dimensions may be ignored win->w_closing = true; @@ -2036,12 +2044,16 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) tabpage_T *ptp = NULL; int free_tp = FALSE; - assert(win->w_buffer); // to avoid np dereference warning in next line - if (win->w_closing || win->w_buffer->b_closing) - return; /* window is already being closed */ + // Get here with win->w_buffer == NULL when win_close() detects the tab page + // changed. + if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing)) { + return; // window is already being closed + } - /* Close the link to the buffer. */ - close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); + if (win->w_buffer != NULL) { + // Close the link to the buffer. + close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); + } /* Careful: Autocommands may have closed the tab page or made it the * current tab page. */ From 9755a2ffd5727c7fc0576e60a21368618978c504 Mon Sep 17 00:00:00 2001 From: Grzegorz Milka Date: Tue, 18 Oct 2016 02:02:47 +0200 Subject: [PATCH 4/6] vim-patch:7.4.2312 Problem: Crash when autocommand moves to another tab. (Dominique Pelle) Solution: When navigating to another window halfway the :edit command go back to the right window. https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5 --- src/nvim/buffer.c | 26 +++++++++++++++++++------- src/nvim/ex_cmds.c | 20 +++++++++----------- src/nvim/ex_docmd.c | 5 +---- src/nvim/ex_getln.c | 8 ++++++-- src/nvim/version.c | 2 +- src/nvim/window.c | 5 +---- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 176967ad2a..fc6e46cf64 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -478,17 +478,20 @@ void buf_clear_file(buf_T *buf) buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ } -/* - * buf_freeall() - free all things allocated for a buffer that are related to - * the file. flags: - * BFA_DEL buffer is going to be deleted - * BFA_WIPE buffer is going to be wiped out - * BFA_KEEP_UNDO do not free undo information - */ +/// buf_freeall() - free all things allocated for a buffer that are related to +/// the file. Careful: get here with "curwin" NULL when exiting. +/// +/// @param flags BFA_DEL buffer is going to be deleted +/// BFA_WIPE buffer is going to be wiped out +/// BFA_KEEP_UNDO do not free undo information void buf_freeall(buf_T *buf, int flags) { bool is_curbuf = (buf == curbuf); + int is_curwin = (curwin != NULL && curwin->w_buffer == buf); + win_T *the_curwin = curwin; + tabpage_T *the_curtab = curtab; + // Make sure the buffer isn't closed by autocommands. buf->b_closing = true; apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf); if (!buf_valid(buf)) /* autocommands may delete the buffer */ @@ -505,6 +508,15 @@ void buf_freeall(buf_T *buf, int flags) return; } buf->b_closing = false; + + // If the buffer was in curwin and the window has changed, go back to that + // window, if it still exists. This avoids that ":edit x" triggering a + // "tabnext" BufUnload autocmd leaves a window behind without a buffer. + if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin)) { + block_autocmds(); + goto_tabpage_win(the_curtab, the_curwin); + unblock_autocmds(); + } if (aborting()) /* autocmds may abort script processing */ return; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 6205daf0cb..79ee69bb56 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2253,25 +2253,23 @@ do_ecmd ( if (buf == curbuf) /* already in new buffer */ auto_buf = TRUE; else { + win_T *the_curwin = curwin; + + // Set the w_closing flag to avoid that autocommands close the window. + the_curwin->w_closing = TRUE; if (curbuf == old_curbuf) buf_copy_options(buf, BCO_ENTER); - /* close the link to the current buffer */ + // Close the link to the current buffer. This will set + // curwin->w_buffer to NULL. u_sync(FALSE); close_buffer(oldwin, curbuf, (flags & ECMD_HIDE) || curbuf->terminal ? 0 : DOBUF_UNLOAD, FALSE); - /* Autocommands may open a new window and leave oldwin open - * which leads to crashes since the above call sets - * oldwin->w_buffer to NULL. */ - if (curwin != oldwin && oldwin != aucmd_win && win_valid(oldwin)) { - assert(oldwin); - if (oldwin->w_buffer == NULL) { - win_close(oldwin, FALSE); - } - } + the_curwin->w_closing = FALSE; - if (aborting()) { /* autocmds may abort script processing */ + // autocmds may abort script processing + if (aborting() && curwin->w_buffer != NULL) { xfree(new_name); goto theend; } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index cbe4d19d2c..5c84b5bb4e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1772,10 +1772,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (text_locked() && !(ea.argt & CMDWIN) && !IS_USER_CMDIDX(ea.cmdidx)) { /* Command not allowed when editing the command line. */ - if (cmdwin_type != 0) - errormsg = (char_u *)_(e_cmdwin); - else - errormsg = (char_u *)_(e_secure); + errormsg = get_text_locked_msg(); goto doend; } /* Disallow editing another buffer when "curbuf_lock" is set. diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7444eb8a38..a58cdd5c6b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1688,10 +1688,14 @@ int text_locked(void) { */ void text_locked_msg(void) { + EMSG(_(get_text_locked_msg())); +} + +char_u * get_text_locked_msg(void) { if (cmdwin_type != 0) - EMSG(_(e_cmdwin)); + return e_cmdwin; else - EMSG(_(e_secure)); + return e_secure; } /* diff --git a/src/nvim/version.c b/src/nvim/version.c index f0f6f6a3cb..389eefdcca 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -129,7 +129,7 @@ static int included_patches[] = { // 2315, // 2314, // 2313, - // 2312, + 2312, // 2311, // 2310 NA 2309, diff --git a/src/nvim/window.c b/src/nvim/window.c index 2fb1fbede9..e7be1fb7f8 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3243,10 +3243,7 @@ void goto_tabpage(int n) if (text_locked()) { /* Not allowed when editing the command line. */ - if (cmdwin_type != 0) - EMSG(_(e_cmdwin)); - else - EMSG(_(e_secure)); + text_locked_msg(); return; } From d357a42389752b5270cf590b2f078f836de6c736 Mon Sep 17 00:00:00 2001 From: Grzegorz Milka Date: Sun, 23 Oct 2016 00:56:15 +0200 Subject: [PATCH 5/6] Fix lint errors. --- src/nvim/buffer.c | 14 ++++++++------ src/nvim/ex_cmds.c | 20 +++++++++++--------- src/nvim/ex_docmd.c | 2 +- src/nvim/ex_getln.c | 5 +++-- src/nvim/window.c | 4 ++-- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fc6e46cf64..e6a7950d53 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -324,12 +324,13 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) } if (win_valid_any_tab(win)) { - /* Set b_last_cursor when closing the last window for the buffer. - * Remember the last cursor position and window options of the buffer. - * This used to be only for the current window, but then options like - * 'foldmethod' may be lost with a ":only" command. */ - if (buf->b_nwindows == 1) + // Set b_last_cursor when closing the last window for the buffer. + // Remember the last cursor position and window options of the buffer. + // This used to be only for the current window, but then options like + // 'foldmethod' may be lost with a ":only" command. + if (buf->b_nwindows == 1) { set_last_cursor(win); + } buflist_setfpos(buf, win, win->w_cursor.lnum == 1 ? 0 : win->w_cursor.lnum, win->w_cursor.col, TRUE); @@ -517,8 +518,9 @@ void buf_freeall(buf_T *buf, int flags) goto_tabpage_win(the_curtab, the_curwin); unblock_autocmds(); } - if (aborting()) /* autocmds may abort script processing */ + if (aborting()) { // autocmds may abort script processing return; + } /* * It's possible that autocommands change curbuf to the one being deleted. diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 79ee69bb56..f19a9206a4 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2250,23 +2250,25 @@ do_ecmd ( xfree(new_name); goto theend; } - if (buf == curbuf) /* already in new buffer */ - auto_buf = TRUE; - else { - win_T *the_curwin = curwin; + if (buf == curbuf) { // already in new buffer + auto_buf = true; + } else { + win_T *the_curwin = curwin; // Set the w_closing flag to avoid that autocommands close the window. - the_curwin->w_closing = TRUE; - if (curbuf == old_curbuf) + the_curwin->w_closing = true; + if (curbuf == old_curbuf) { buf_copy_options(buf, BCO_ENTER); + } // Close the link to the current buffer. This will set // curwin->w_buffer to NULL. - u_sync(FALSE); + u_sync(false); close_buffer(oldwin, curbuf, - (flags & ECMD_HIDE) || curbuf->terminal ? 0 : DOBUF_UNLOAD, FALSE); + (flags & ECMD_HIDE) || curbuf->terminal ? 0 : DOBUF_UNLOAD, + false); - the_curwin->w_closing = FALSE; + the_curwin->w_closing = false; // autocmds may abort script processing if (aborting() && curwin->w_buffer != NULL) { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5c84b5bb4e..5e418bf099 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1771,7 +1771,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (text_locked() && !(ea.argt & CMDWIN) && !IS_USER_CMDIDX(ea.cmdidx)) { - /* Command not allowed when editing the command line. */ + // Command not allowed when editing the command line. errormsg = get_text_locked_msg(); goto doend; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a58cdd5c6b..e525c949bd 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1692,10 +1692,11 @@ void text_locked_msg(void) } char_u * get_text_locked_msg(void) { - if (cmdwin_type != 0) + if (cmdwin_type != 0) { return e_cmdwin; - else + } else { return e_secure; + } } /* diff --git a/src/nvim/window.c b/src/nvim/window.c index e7be1fb7f8..9c6a2e26a6 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2052,7 +2052,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) if (win->w_buffer != NULL) { // Close the link to the buffer. - close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); + close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, false); } /* Careful: Autocommands may have closed the tab page or made it the @@ -3242,7 +3242,7 @@ void goto_tabpage(int n) int i; if (text_locked()) { - /* Not allowed when editing the command line. */ + // Not allowed when editing the command line. text_locked_msg(); return; } From 26b90e95e7bfa8bec29d33642c80dd5c55ff88a7 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 26 Oct 2016 13:53:14 +0200 Subject: [PATCH 6/6] test: Add missing test from vim-patch:7.4.2312 --- src/nvim/testdir/test_tabpage.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index 7bdea0b186..0bf7d056de 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -218,7 +218,7 @@ function Test_tabpage_with_tab_modifier() bw! endfunction -func Test_tabnext_on_buf_unload() +func Test_tabnext_on_buf_unload1() " This once caused a crash new tabedit @@ -227,7 +227,19 @@ func Test_tabnext_on_buf_unload() q while tabpagenr('$') > 1 - quit + bwipe! + endwhile +endfunc + +func Test_tabnext_on_buf_unload2() + " This once caused a crash + tabedit + autocmd BufUnload tabnext + file x + edit y + + while tabpagenr('$') > 1 + bwipe! endwhile endfunc