]> granicus.if.org Git - vim/commitdiff
patch 8.1.0630: "wincmd p" does not work after using an autocmd window v8.1.0630
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Dec 2018 23:22:39 +0000 (00:22 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Dec 2018 23:22:39 +0000 (00:22 +0100)
Problem:   "wincmd p" does not work after using an autocmd window.
Solution:   Store "prevwin" in aco_save_T. (Christian Brabandt, closes #3690)

src/fileio.c
src/structs.h
src/testdir/test_window_cmd.vim
src/version.c

index bf46522b92e850313579405708ef3c54b15b5a8d..fd8fd243fd5ab02123e0662ed5a86c8c4e20a77a 100644 (file)
@@ -9017,6 +9017,7 @@ aucmd_prepbuf(
 
     aco->save_curwin = curwin;
     aco->save_curbuf = curbuf;
+    aco->save_prevwin = prevwin;
     if (win != NULL)
     {
        /* There is a window for "buf" in the current tab page, make it the
@@ -9127,6 +9128,8 @@ win_found:
        else
            /* Hmm, original window disappeared.  Just use the first one. */
            curwin = firstwin;
+       if (win_valid(aco->save_prevwin))
+           prevwin = aco->save_prevwin;
 #ifdef FEAT_EVAL
        vars_clear(&aucmd_win->w_vars->dv_hashtab);  /* free all w: variables */
        hash_init(&aucmd_win->w_vars->dv_hashtab);   /* re-use the hashtab */
@@ -9177,6 +9180,8 @@ win_found:
 
            curwin = aco->save_curwin;
            curbuf = curwin->w_buffer;
+           if (win_valid(aco->save_prevwin))
+               prevwin = aco->save_prevwin;
            /* In case the autocommand move the cursor to a position that that
             * not exist in curbuf. */
            check_cursor();
index 09a566571aeaadac9ce085da4300f78ce516f318..0f37b8f66bfc1f97ec68c3ad32d94d5f21069015 100644 (file)
@@ -3252,6 +3252,7 @@ typedef struct
     int                use_aucmd_win;  /* using aucmd_win */
     win_T      *save_curwin;   /* saved curwin */
     win_T      *new_curwin;    /* new curwin */
+    win_T      *save_prevwin;  /* saved prevwin */
     bufref_T   new_curbuf;     /* new curbuf */
     char_u     *globaldir;     /* saved value of globaldir */
 } aco_save_T;
index 6d65e2b29c57467a70fa00f48ed024bb3a688cb2..0980493fe87fc9d3762f5aabc13fe662906a9d17 100644 (file)
@@ -578,4 +578,41 @@ func Test_winrestcmd()
   only
 endfunc
 
+function! Fun_RenewFile()
+  sleep 2
+  silent execute '!echo "1" > tmp.txt'
+  sp
+  wincmd p
+  edit! tmp.txt
+endfunction
+
+func Test_window_prevwin()
+  " Can we make this work on MS-Windows?
+  if !has('unix')
+    return
+  endif
+
+  set hidden autoread
+  call writefile(['2'], 'tmp.txt')
+  new tmp.txt
+  q
+  " Need to wait a bit for the timestamp to be older.
+  call Fun_RenewFile()
+  call assert_equal(2, winnr())
+  wincmd p
+  call assert_equal(1, winnr())
+  wincmd p
+  q
+  call Fun_RenewFile()
+  call assert_equal(2, winnr())
+  wincmd p
+  call assert_equal(1, winnr())
+  wincmd p
+  " reset
+  q
+  call delete('tmp.txt')
+  set hidden&vim autoread&vim
+  delfunc Fun_RenewFile
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 2155834dbf19b169ef5d46fbd4a3f50817b45bf6..1b9e3e0dcb00751f1469b38ad38f311f875d4855 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    630,
 /**/
     629,
 /**/