To: vim-dev@vim.org
Subject: Patch 6.0.216
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.0.216
Problem:    After reloading a file, displayed in another window than the
	    current one, which was changed outside of Vim the part of the file
	    around the cursor set by autocommands may be displayed, but
	    jumping back to the original cursor position when entering the
	    window again.
Solution:   Restore the topline of the window.
Files:	    src/fileio.c


*** ../vim60.215/src/fileio.c	Mon Feb 11 14:00:48 2002
--- src/fileio.c	Mon Feb 11 16:46:53 2002
***************
*** 5174,5179 ****
--- 5182,5188 ----
  	linenr_T	old_line_count = buf->b_ml.ml_line_count;
  	exarg_T		ea;
  	pos_T		old_cursor;
+ 	linenr_T	old_topline;
  	int		old_ro = curbuf->b_p_ro;
  #ifdef FEAT_AUTOCMD
  	aco_save_T	aco;
***************
*** 5193,5198 ****
--- 5202,5208 ----
  	if (prep_exarg(&ea, buf) == OK)
  	{
  	    old_cursor = curwin->w_cursor;
+ 	    old_topline = curwin->w_topline;
  	    if (bufempty())
  		old_line_count = 0;
  	    curbuf->b_flags |= BF_CHECK_RO;	/* check for RO again */
***************
*** 5214,5223 ****
  	    }
  	    vim_free(ea.cmd);
  
! 	    /* Restore the cursor position and check it (lines may have been
! 	     * removed). */
  	    curwin->w_cursor = old_cursor;
  	    check_cursor();
  #ifdef FEAT_AUTOCMD
  	    keep_filetype = FALSE;
  #endif
--- 5224,5238 ----
  	    }
  	    vim_free(ea.cmd);
  
! 	    /* Restore the topline and cursor position and check it (lines may
! 	     * have been removed). */
! 	    if (old_topline > curbuf->b_ml.ml_line_count)
! 		curwin->w_topline = curbuf->b_ml.ml_line_count;
! 	    else
! 		curwin->w_topline = old_topline;
  	    curwin->w_cursor = old_cursor;
  	    check_cursor();
+ 	    update_topline();
  #ifdef FEAT_AUTOCMD
  	    keep_filetype = FALSE;
  #endif
*** ../vim60.215/src/version.c	Mon Feb 11 15:45:47 2002
--- src/version.c	Mon Feb 11 16:55:17 2002
***************
*** 608,609 ****
--- 608,611 ----
  {   /* Add new patch number below this line */
+ /**/
+     216,
  /**/

-- 
WOMAN:   Dennis, there's some lovely filth down here.  Oh -- how d'you do?
ARTHUR:  How do you do, good lady.  I am Arthur, King of the Britons.
         Who's castle is that?
WOMAN:   King of the who?
                                  The Quest for the Holy Grail (Monty Python)

 ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
(((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
 \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///