To: vim_dev@googlegroups.com Subject: Patch 7.4.2212 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 #974) Files: src/window.c, src/proto/window.pro, src/buffer.c, src/testdir/test_viminfo.vim *** ../vim-7.4.2211/src/window.c 2016-08-12 22:22:01.176781877 +0200 --- src/window.c 2016-08-14 18:43:32.383892467 +0200 *************** *** 1358,1364 **** #if defined(FEAT_WINDOWS) || defined(PROTO) /* ! * Check if "win" is a pointer to an existing window. */ int win_valid(win_T *win) --- 1358,1364 ---- #if defined(FEAT_WINDOWS) || defined(PROTO) /* ! * Check if "win" is a pointer to an existing window in the current tab page. */ int win_valid(win_T *win) *************** *** 1373,1378 **** --- 1373,1400 ---- return FALSE; } + /* + * Check if "win" is a pointer to an existing window in any tab page. + */ + int + win_valid_any_tab(win_T *win) + { + win_T *wp; + tabpage_T *tp; + + if (win == NULL) + return FALSE; + FOR_ALL_TABPAGES(tp) + { + FOR_ALL_WINDOWS_IN_TAB(tp, wp) + { + if (wp == win) + return TRUE; + } + } + return FALSE; + } + /* * Return the number of windows. */ *** ../vim-7.4.2211/src/proto/window.pro 2016-08-12 22:22:01.172781914 +0200 --- src/proto/window.pro 2016-08-14 18:45:56.986566034 +0200 *************** *** 4,9 **** --- 4,10 ---- int win_split(int size, int flags); int win_split_ins(int size, int flags, win_T *new_wp, int dir); int win_valid(win_T *win); + int win_valid_any_tab(win_T *win); int win_count(void); int make_windows(int count, int vertical); void win_move_after(win_T *win1, win_T *win2); *** ../vim-7.4.2211/src/buffer.c 2016-08-09 22:13:51.854043851 +0200 --- src/buffer.c 2016-08-14 18:45:43.986685286 +0200 *************** *** 475,481 **** if (win != NULL #ifdef FEAT_WINDOWS ! && win_valid(win) /* in case autocommands closed the window */ #endif ) { --- 475,481 ---- if (win != NULL #ifdef FEAT_WINDOWS ! && win_valid_any_tab(win) /* in case autocommands closed the window */ #endif ) { *************** *** 581,587 **** if ( #ifdef FEAT_WINDOWS ! win_valid(win) && #else win != NULL && #endif --- 581,587 ---- if ( #ifdef FEAT_WINDOWS ! win_valid_any_tab(win) && #else win != NULL && #endif *** ../vim-7.4.2211/src/testdir/test_viminfo.vim 2016-07-03 17:47:21.862812533 +0200 --- src/testdir/test_viminfo.vim 2016-08-14 19:02:09.685628348 +0200 *************** *** 425,427 **** --- 425,457 ---- call delete('Xviminfo') endfunc + + func Test_viminfo_file_mark_tabclose() + tabnew Xtestfileintab + call setline(1, ['a','b','c','d','e']) + 4 + q! + wviminfo Xviminfo + sp Xviminfo + /^> .*Xtestfileintab + let lnum = line('.') + while 1 + if lnum == line('$') + call assert_false(1, 'mark not found in Xtestfileintab') + break + endif + let lnum += 1 + let line = getline(lnum) + if line == '' + call assert_false(1, 'mark not found in Xtestfileintab') + break + endif + if line =~ "^\t\"" + call assert_equal('4', substitute(line, ".*\"\t\\(\\d\\).*", '\1', '')) + break + endif + endwhile + + call delete('Xviminfo') + silent! bwipe Xtestfileintab + endfunc *** ../vim-7.4.2211/src/version.c 2016-08-14 18:23:16.759039502 +0200 --- src/version.c 2016-08-14 18:44:56.695119096 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2212, /**/ -- Don't Panic! -- The Hitchhiker's Guide to the Galaxy /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///