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