]> granicus.if.org Git - vim/commitdiff
patch 7.4.2212 v7.4.2212
authorBram Moolenaar <Bram@vim.org>
Sun, 14 Aug 2016 17:08:45 +0000 (19:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 14 Aug 2016 17:08:45 +0000 (19:08 +0200)
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)

src/buffer.c
src/proto/window.pro
src/testdir/test_viminfo.vim
src/version.c
src/window.c

index 2a09a6308b0eaeea43f747a656c2cf63bef7c64f..4f688825583a0e1bed4a0ee60f03adf5c5c6bbd7 100644 (file)
@@ -475,7 +475,7 @@ close_buffer(
 
     if (win != NULL
 #ifdef FEAT_WINDOWS
-       && win_valid(win)       /* in case autocommands closed the window */
+       && win_valid_any_tab(win) /* in case autocommands closed the window */
 #endif
            )
     {
@@ -581,7 +581,7 @@ aucmd_abort:
 
     if (
 #ifdef FEAT_WINDOWS
-       win_valid(win) &&
+       win_valid_any_tab(win) &&
 #else
        win != NULL &&
 #endif
index ebd71ed95170e0009d2d80b8c6f70ec50f9bc82d..d82988e30b8c735454dc254679a39dfbee0371e9 100644 (file)
@@ -4,6 +4,7 @@ void get_wincmd_addr_type(char_u *arg, exarg_T *eap);
 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);
index 4c4935b92e52b0bfed53f5a9a930494d7de7846c..cbe481c594d24f4fa26838d38a2eeaabf59d27c5 100644 (file)
@@ -425,3 +425,33 @@ func Test_viminfo_file_marks()
 
   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
index 9be301f1d4d637ad5ae7bc6636ce995dce8f5ca5..c2900c18d2ae82a2740746381dc5fadc1716c88a 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2212,
 /**/
     2211,
 /**/
index c6409e1e0342ebda97024614f72b2d8316190eb8..b015d1d01f3b42b5cb2c244399e07079ab94f139 100644 (file)
@@ -1358,7 +1358,7 @@ win_init_some(win_T *newp, win_T *oldp)
 
 #if defined(FEAT_WINDOWS) || defined(PROTO)
 /*
- * Check if "win" is a pointer to an existing window.
+ * Check if "win" is a pointer to an existing window in the current tab page.
  */
     int
 win_valid(win_T *win)
@@ -1373,6 +1373,28 @@ win_valid(win_T *win)
     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.
  */