Karsten Hopp 52353d
To: vim_dev@googlegroups.com
Karsten Hopp 52353d
Subject: Patch 7.4.280
Karsten Hopp 52353d
Fcc: outbox
Karsten Hopp 52353d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 52353d
Mime-Version: 1.0
Karsten Hopp 52353d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 52353d
Content-Transfer-Encoding: 8bit
Karsten Hopp 52353d
------------
Karsten Hopp 52353d
Karsten Hopp 52353d
Patch 7.4.280
Karsten Hopp 52353d
Problem:    When using a session file the relative position of the cursor is
Karsten Hopp 52353d
	    not restored if there is another tab. (Nobuhiro Takasaki)
Karsten Hopp 52353d
Solution:   Update w_wrow before calculating the fraction.
Karsten Hopp 52353d
Files:	    src/window.c
Karsten Hopp 52353d
Karsten Hopp 52353d
Karsten Hopp 52353d
*** ../vim-7.4.279/src/window.c	2014-03-23 15:12:29.943264337 +0100
Karsten Hopp 52353d
--- src/window.c	2014-05-07 20:18:55.237270409 +0200
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 5623,5629 ****
Karsten Hopp 52353d
      win_T	*wp;
Karsten Hopp 52353d
  {
Karsten Hopp 52353d
      wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
Karsten Hopp 52353d
! 				    + FRACTION_MULT / 2) / (long)wp->w_height;
Karsten Hopp 52353d
  }
Karsten Hopp 52353d
  
Karsten Hopp 52353d
  /*
Karsten Hopp 52353d
--- 5623,5629 ----
Karsten Hopp 52353d
      win_T	*wp;
Karsten Hopp 52353d
  {
Karsten Hopp 52353d
      wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
Karsten Hopp 52353d
! 				    + wp->w_height / 2) / (long)wp->w_height;
Karsten Hopp 52353d
  }
Karsten Hopp 52353d
  
Karsten Hopp 52353d
  /*
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 5638,5643 ****
Karsten Hopp 52353d
--- 5638,5644 ----
Karsten Hopp 52353d
  {
Karsten Hopp 52353d
      linenr_T	lnum;
Karsten Hopp 52353d
      int		sline, line_size;
Karsten Hopp 52353d
+     int		prev_height = wp->w_height;
Karsten Hopp 52353d
  
Karsten Hopp 52353d
      /* Don't want a negative height.  Happens when splitting a tiny window.
Karsten Hopp 52353d
       * Will equalize heights soon to fix it. */
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 5646,5653 ****
Karsten Hopp 52353d
      if (wp->w_height == height)
Karsten Hopp 52353d
  	return;	    /* nothing to do */
Karsten Hopp 52353d
  
Karsten Hopp 52353d
!     if (wp->w_wrow != wp->w_prev_fraction_row && wp->w_height > 0)
Karsten Hopp 52353d
! 	set_fraction(wp);
Karsten Hopp 52353d
  
Karsten Hopp 52353d
      wp->w_height = height;
Karsten Hopp 52353d
      wp->w_skipcol = 0;
Karsten Hopp 52353d
--- 5647,5659 ----
Karsten Hopp 52353d
      if (wp->w_height == height)
Karsten Hopp 52353d
  	return;	    /* nothing to do */
Karsten Hopp 52353d
  
Karsten Hopp 52353d
!     if (wp->w_height > 0)
Karsten Hopp 52353d
!     {
Karsten Hopp 52353d
! 	if (wp == curwin)
Karsten Hopp 52353d
! 	    validate_cursor();		/* w_wrow needs to be valid */
Karsten Hopp 52353d
! 	if (wp->w_wrow != wp->w_prev_fraction_row)
Karsten Hopp 52353d
! 	    set_fraction(wp);
Karsten Hopp 52353d
!     }
Karsten Hopp 52353d
  
Karsten Hopp 52353d
      wp->w_height = height;
Karsten Hopp 52353d
      wp->w_skipcol = 0;
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 5667,5673 ****
Karsten Hopp 52353d
  	lnum = wp->w_cursor.lnum;
Karsten Hopp 52353d
  	if (lnum < 1)		/* can happen when starting up */
Karsten Hopp 52353d
  	    lnum = 1;
Karsten Hopp 52353d
! 	wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L) / FRACTION_MULT;
Karsten Hopp 52353d
  	line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1;
Karsten Hopp 52353d
  	sline = wp->w_wrow - line_size;
Karsten Hopp 52353d
  
Karsten Hopp 52353d
--- 5673,5680 ----
Karsten Hopp 52353d
  	lnum = wp->w_cursor.lnum;
Karsten Hopp 52353d
  	if (lnum < 1)		/* can happen when starting up */
Karsten Hopp 52353d
  	    lnum = 1;
Karsten Hopp 52353d
! 	wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L
Karsten Hopp 52353d
! 					 + FRACTION_MULT / 2) / FRACTION_MULT;
Karsten Hopp 52353d
  	line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1;
Karsten Hopp 52353d
  	sline = wp->w_wrow - line_size;
Karsten Hopp 52353d
  
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 5757,5763 ****
Karsten Hopp 52353d
  	    update_topline();
Karsten Hopp 52353d
  	curs_columns(FALSE);	/* validate w_wrow */
Karsten Hopp 52353d
      }
Karsten Hopp 52353d
!     wp->w_prev_fraction_row = wp->w_wrow;
Karsten Hopp 52353d
  
Karsten Hopp 52353d
      win_comp_scroll(wp);
Karsten Hopp 52353d
      redraw_win_later(wp, SOME_VALID);
Karsten Hopp 52353d
--- 5764,5771 ----
Karsten Hopp 52353d
  	    update_topline();
Karsten Hopp 52353d
  	curs_columns(FALSE);	/* validate w_wrow */
Karsten Hopp 52353d
      }
Karsten Hopp 52353d
!     if (prev_height > 0)
Karsten Hopp 52353d
! 	wp->w_prev_fraction_row = wp->w_wrow;
Karsten Hopp 52353d
  
Karsten Hopp 52353d
      win_comp_scroll(wp);
Karsten Hopp 52353d
      redraw_win_later(wp, SOME_VALID);
Karsten Hopp 52353d
*** ../vim-7.4.279/src/version.c	2014-05-07 18:35:25.669216052 +0200
Karsten Hopp 52353d
--- src/version.c	2014-05-07 20:24:14.313273202 +0200
Karsten Hopp 52353d
***************
Karsten Hopp 52353d
*** 736,737 ****
Karsten Hopp 52353d
--- 736,739 ----
Karsten Hopp 52353d
  {   /* Add new patch number below this line */
Karsten Hopp 52353d
+ /**/
Karsten Hopp 52353d
+     280,
Karsten Hopp 52353d
  /**/
Karsten Hopp 52353d
Karsten Hopp 52353d
-- 
Karsten Hopp 52353d
~
Karsten Hopp 52353d
~
Karsten Hopp 52353d
~
Karsten Hopp 52353d
".signature" 4 lines, 50 characters written
Karsten Hopp 52353d
Karsten Hopp 52353d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 52353d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 52353d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 52353d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///