60da636
To: vim_dev@googlegroups.com
60da636
Subject: Patch 7.3.084
60da636
Fcc: outbox
60da636
From: Bram Moolenaar <Bram@moolenaar.net>
60da636
Mime-Version: 1.0
60da636
Content-Type: text/plain; charset=UTF-8
60da636
Content-Transfer-Encoding: 8bit
60da636
------------
60da636
60da636
Patch 7.3.084
60da636
Problem:    When splitting the window, the new one scrolls with the cursor at
60da636
	    the top.
60da636
Solution:   Compute w_fraction before setting the new height.
60da636
Files:	    src/window.c
60da636
60da636
60da636
*** ../vim-7.3.083/src/window.c	2010-09-21 16:56:29.000000000 +0200
60da636
--- src/window.c	2010-12-17 17:09:51.000000000 +0100
60da636
***************
60da636
*** 70,76 ****
60da636
  #endif /* FEAT_WINDOWS */
60da636
  
60da636
  static win_T *win_alloc __ARGS((win_T *after, int hidden));
60da636
! static void win_new_height __ARGS((win_T *, int));
60da636
  
60da636
  #define URL_SLASH	1		/* path_is_url() has found "://" */
60da636
  #define URL_BACKSLASH	2		/* path_is_url() has found ":\\" */
60da636
--- 70,77 ----
60da636
  #endif /* FEAT_WINDOWS */
60da636
  
60da636
  static win_T *win_alloc __ARGS((win_T *after, int hidden));
60da636
! static void set_fraction __ARGS((win_T *wp));
60da636
! static void win_new_height __ARGS((win_T *wp, int height));
60da636
  
60da636
  #define URL_SLASH	1		/* path_is_url() has found "://" */
60da636
  #define URL_BACKSLASH	2		/* path_is_url() has found ":\\" */
60da636
***************
60da636
*** 983,992 ****
60da636
--- 984,999 ----
60da636
      else
60da636
  	frame_append(curfrp, frp);
60da636
  
60da636
+     /* Set w_fraction now so that the cursor keeps the same relative
60da636
+      * vertical position. */
60da636
+     set_fraction(oldwin);
60da636
+     wp->w_fraction = oldwin->w_fraction;
60da636
+ 
60da636
  #ifdef FEAT_VERTSPLIT
60da636
      if (flags & WSP_VERT)
60da636
      {
60da636
  	wp->w_p_scr = curwin->w_p_scr;
60da636
+ 
60da636
  	if (need_status)
60da636
  	{
60da636
  	    win_new_height(oldwin, oldwin->w_height - 1);
60da636
***************
60da636
*** 5453,5458 ****
60da636
--- 5460,5478 ----
60da636
  
60da636
  #endif /* FEAT_WINDOWS */
60da636
  
60da636
+ #define FRACTION_MULT	16384L
60da636
+ 
60da636
+ /*
60da636
+  * Set wp->w_fraction for the current w_wrow and w_height.
60da636
+  */
60da636
+     static void
60da636
+ set_fraction(wp)
60da636
+     win_T	*wp;
60da636
+ {
60da636
+     wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
60da636
+ 				    + FRACTION_MULT / 2) / (long)wp->w_height;
60da636
+ }
60da636
+ 
60da636
  /*
60da636
   * Set the height of a window.
60da636
   * This takes care of the things inside the window, not what happens to the
60da636
***************
60da636
*** 5465,5471 ****
60da636
  {
60da636
      linenr_T	lnum;
60da636
      int		sline, line_size;
60da636
- #define FRACTION_MULT	16384L
60da636
  
60da636
      /* Don't want a negative height.  Happens when splitting a tiny window.
60da636
       * Will equalize heights soon to fix it. */
60da636
--- 5485,5490 ----
60da636
***************
60da636
*** 5475,5482 ****
60da636
  	return;	    /* nothing to do */
60da636
  
60da636
      if (wp->w_wrow != wp->w_prev_fraction_row && wp->w_height > 0)
60da636
! 	wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
60da636
! 				    + FRACTION_MULT / 2) / (long)wp->w_height;
60da636
  
60da636
      wp->w_height = height;
60da636
      wp->w_skipcol = 0;
60da636
--- 5494,5500 ----
60da636
  	return;	    /* nothing to do */
60da636
  
60da636
      if (wp->w_wrow != wp->w_prev_fraction_row && wp->w_height > 0)
60da636
! 	set_fraction(wp);
60da636
  
60da636
      wp->w_height = height;
60da636
      wp->w_skipcol = 0;
60da636
*** ../vim-7.3.083/src/version.c	2010-12-17 16:27:10.000000000 +0100
60da636
--- src/version.c	2010-12-17 17:14:19.000000000 +0100
60da636
***************
60da636
*** 716,717 ****
60da636
--- 716,719 ----
60da636
  {   /* Add new patch number below this line */
60da636
+ /**/
60da636
+     84,
60da636
  /**/
60da636
60da636
-- 
60da636
How To Keep A Healthy Level Of Insanity:
60da636
12. Sing along at the opera.
60da636
60da636
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
60da636
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
60da636
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
60da636
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///