Karsten Hopp 41d017
To: vim_dev@googlegroups.com
Karsten Hopp 41d017
Subject: Patch 7.4.603
Karsten Hopp 41d017
Fcc: outbox
Karsten Hopp 41d017
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 41d017
Mime-Version: 1.0
Karsten Hopp 41d017
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 41d017
Content-Transfer-Encoding: 8bit
Karsten Hopp 41d017
------------
Karsten Hopp 41d017
Karsten Hopp 41d017
Patch 7.4.603
Karsten Hopp 41d017
Problem:    'foldcolumn' may be set such that it fills the whole window, not
Karsten Hopp 41d017
	    leaving space for text.
Karsten Hopp 41d017
Solution:   Reduce the foldcolumn width when there is not sufficient room.
Karsten Hopp 41d017
	    (idea by Christian Brabandt)
Karsten Hopp 41d017
Files:	    src/srcreen.c
Karsten Hopp 41d017
Karsten Hopp 41d017
Karsten Hopp 41d017
*** ../vim-7.4.602/src/screen.c	2015-01-20 19:01:32.380444290 +0100
Karsten Hopp 41d017
--- src/screen.c	2015-01-27 16:25:47.264690419 +0100
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 109,114 ****
Karsten Hopp 41d017
--- 109,115 ----
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
  static foldinfo_T win_foldinfo;	/* info for 'foldcolumn' */
Karsten Hopp 41d017
+ static int compute_foldcolumn __ARGS((win_T *wp, int col));
Karsten Hopp 41d017
  #endif
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  /*
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 1202,1208 ****
Karsten Hopp 41d017
  			lnumb = wp->w_lines[i].wl_lnum;
Karsten Hopp 41d017
  			/* When there is a fold column it might need updating
Karsten Hopp 41d017
  			 * in the next line ("J" just above an open fold). */
Karsten Hopp 41d017
! 			if (wp->w_p_fdc > 0)
Karsten Hopp 41d017
  			    ++lnumb;
Karsten Hopp 41d017
  		    }
Karsten Hopp 41d017
  		}
Karsten Hopp 41d017
--- 1203,1209 ----
Karsten Hopp 41d017
  			lnumb = wp->w_lines[i].wl_lnum;
Karsten Hopp 41d017
  			/* When there is a fold column it might need updating
Karsten Hopp 41d017
  			 * in the next line ("J" just above an open fold). */
Karsten Hopp 41d017
! 			if (compute_foldcolumn(wp, 0) > 0)
Karsten Hopp 41d017
  			    ++lnumb;
Karsten Hopp 41d017
  		    }
Karsten Hopp 41d017
  		}
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2238,2250 ****
Karsten Hopp 41d017
  #else
Karsten Hopp 41d017
  # define FDC_OFF 0
Karsten Hopp 41d017
  #endif
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  #ifdef FEAT_RIGHTLEFT
Karsten Hopp 41d017
      if (wp->w_p_rl)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	/* No check for cmdline window: should never be right-left. */
Karsten Hopp 41d017
  # ifdef FEAT_FOLDING
Karsten Hopp 41d017
! 	n = wp->w_p_fdc;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	if (n > 0)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
--- 2239,2254 ----
Karsten Hopp 41d017
  #else
Karsten Hopp 41d017
  # define FDC_OFF 0
Karsten Hopp 41d017
  #endif
Karsten Hopp 41d017
+ #ifdef FEAT_FOLDING
Karsten Hopp 41d017
+     int		fdc = compute_foldcolumn(wp, 0);
Karsten Hopp 41d017
+ #endif
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  #ifdef FEAT_RIGHTLEFT
Karsten Hopp 41d017
      if (wp->w_p_rl)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	/* No check for cmdline window: should never be right-left. */
Karsten Hopp 41d017
  # ifdef FEAT_FOLDING
Karsten Hopp 41d017
! 	n = fdc;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	if (n > 0)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2293,2301 ****
Karsten Hopp 41d017
  	}
Karsten Hopp 41d017
  #endif
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
! 	if (wp->w_p_fdc > 0)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
! 	    int	    nn = n + wp->w_p_fdc;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	    /* draw the fold column at the left */
Karsten Hopp 41d017
  	    if (nn > W_WIDTH(wp))
Karsten Hopp 41d017
--- 2297,2305 ----
Karsten Hopp 41d017
  	}
Karsten Hopp 41d017
  #endif
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
! 	if (fdc > 0)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
! 	    int	    nn = n + fdc;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	    /* draw the fold column at the left */
Karsten Hopp 41d017
  	    if (nn > W_WIDTH(wp))
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2346,2351 ****
Karsten Hopp 41d017
--- 2350,2373 ----
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
  /*
Karsten Hopp 41d017
+  * Compute the width of the foldcolumn.  Based on 'foldcolumn' and how much
Karsten Hopp 41d017
+  * space is available for window "wp", minus "col".
Karsten Hopp 41d017
+  */
Karsten Hopp 41d017
+     static int
Karsten Hopp 41d017
+ compute_foldcolumn(wp, col)
Karsten Hopp 41d017
+     win_T *wp;
Karsten Hopp 41d017
+     int   col;
Karsten Hopp 41d017
+ {
Karsten Hopp 41d017
+     int fdc = wp->w_p_fdc;
Karsten Hopp 41d017
+     int wmw = wp == curwin && p_wmw == 0 ? 1 : p_wmw;
Karsten Hopp 41d017
+     int wwidth = W_WIDTH(wp);
Karsten Hopp 41d017
+ 
Karsten Hopp 41d017
+     if (fdc > wwidth - (col + wmw))
Karsten Hopp 41d017
+ 	fdc = wwidth - (col + wmw);
Karsten Hopp 41d017
+     return fdc;
Karsten Hopp 41d017
+ }
Karsten Hopp 41d017
+ 
Karsten Hopp 41d017
+ /*
Karsten Hopp 41d017
   * Display one folded line.
Karsten Hopp 41d017
   */
Karsten Hopp 41d017
      static void
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2396,2405 ****
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      /*
Karsten Hopp 41d017
       * 2. Add the 'foldcolumn'
Karsten Hopp 41d017
       */
Karsten Hopp 41d017
!     fdc = wp->w_p_fdc;
Karsten Hopp 41d017
!     if (fdc > W_WIDTH(wp) - col)
Karsten Hopp 41d017
! 	fdc = W_WIDTH(wp) - col;
Karsten Hopp 41d017
      if (fdc > 0)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	fill_foldcolumn(buf, wp, TRUE, lnum);
Karsten Hopp 41d017
--- 2418,2426 ----
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      /*
Karsten Hopp 41d017
       * 2. Add the 'foldcolumn'
Karsten Hopp 41d017
+      *    Reduce the width when there is not enough space.
Karsten Hopp 41d017
       */
Karsten Hopp 41d017
!     fdc = compute_foldcolumn(wp, col);
Karsten Hopp 41d017
      if (fdc > 0)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	fill_foldcolumn(buf, wp, TRUE, lnum);
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2787,2809 ****
Karsten Hopp 41d017
      int		level;
Karsten Hopp 41d017
      int		first_level;
Karsten Hopp 41d017
      int		empty;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      /* Init to all spaces. */
Karsten Hopp 41d017
!     copy_spaces(p, (size_t)wp->w_p_fdc);
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      level = win_foldinfo.fi_level;
Karsten Hopp 41d017
      if (level > 0)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	/* If there is only one column put more info in it. */
Karsten Hopp 41d017
! 	empty = (wp->w_p_fdc == 1) ? 0 : 1;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	/* If the column is too narrow, we start at the lowest level that
Karsten Hopp 41d017
  	 * fits and use numbers to indicated the depth. */
Karsten Hopp 41d017
! 	first_level = level - wp->w_p_fdc - closed + 1 + empty;
Karsten Hopp 41d017
  	if (first_level < 1)
Karsten Hopp 41d017
  	    first_level = 1;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
! 	for (i = 0; i + empty < wp->w_p_fdc; ++i)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
  	    if (win_foldinfo.fi_lnum == lnum
Karsten Hopp 41d017
  			      && first_level + i >= win_foldinfo.fi_low_level)
Karsten Hopp 41d017
--- 2808,2831 ----
Karsten Hopp 41d017
      int		level;
Karsten Hopp 41d017
      int		first_level;
Karsten Hopp 41d017
      int		empty;
Karsten Hopp 41d017
+     int		fdc = compute_foldcolumn(wp, 0);
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      /* Init to all spaces. */
Karsten Hopp 41d017
!     copy_spaces(p, (size_t)fdc);
Karsten Hopp 41d017
  
Karsten Hopp 41d017
      level = win_foldinfo.fi_level;
Karsten Hopp 41d017
      if (level > 0)
Karsten Hopp 41d017
      {
Karsten Hopp 41d017
  	/* If there is only one column put more info in it. */
Karsten Hopp 41d017
! 	empty = (fdc == 1) ? 0 : 1;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
  	/* If the column is too narrow, we start at the lowest level that
Karsten Hopp 41d017
  	 * fits and use numbers to indicated the depth. */
Karsten Hopp 41d017
! 	first_level = level - fdc - closed + 1 + empty;
Karsten Hopp 41d017
  	if (first_level < 1)
Karsten Hopp 41d017
  	    first_level = 1;
Karsten Hopp 41d017
  
Karsten Hopp 41d017
! 	for (i = 0; i + empty < fdc; ++i)
Karsten Hopp 41d017
  	{
Karsten Hopp 41d017
  	    if (win_foldinfo.fi_lnum == lnum
Karsten Hopp 41d017
  			      && first_level + i >= win_foldinfo.fi_low_level)
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 2819,2825 ****
Karsten Hopp 41d017
  	}
Karsten Hopp 41d017
      }
Karsten Hopp 41d017
      if (closed)
Karsten Hopp 41d017
! 	p[i >= wp->w_p_fdc ? i - 1 : i] = '+';
Karsten Hopp 41d017
  }
Karsten Hopp 41d017
  #endif /* FEAT_FOLDING */
Karsten Hopp 41d017
  
Karsten Hopp 41d017
--- 2841,2847 ----
Karsten Hopp 41d017
  	}
Karsten Hopp 41d017
      }
Karsten Hopp 41d017
      if (closed)
Karsten Hopp 41d017
! 	p[i >= fdc ? i - 1 : i] = '+';
Karsten Hopp 41d017
  }
Karsten Hopp 41d017
  #endif /* FEAT_FOLDING */
Karsten Hopp 41d017
  
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 3556,3567 ****
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
  	    if (draw_state == WL_FOLD - 1 && n_extra == 0)
Karsten Hopp 41d017
  	    {
Karsten Hopp 41d017
  		draw_state = WL_FOLD;
Karsten Hopp 41d017
! 		if (wp->w_p_fdc > 0)
Karsten Hopp 41d017
  		{
Karsten Hopp 41d017
  		    /* Draw the 'foldcolumn'. */
Karsten Hopp 41d017
  		    fill_foldcolumn(extra, wp, FALSE, lnum);
Karsten Hopp 41d017
! 		    n_extra = wp->w_p_fdc;
Karsten Hopp 41d017
  		    p_extra = extra;
Karsten Hopp 41d017
  		    p_extra[n_extra] = NUL;
Karsten Hopp 41d017
  		    c_extra = NUL;
Karsten Hopp 41d017
--- 3578,3591 ----
Karsten Hopp 41d017
  #ifdef FEAT_FOLDING
Karsten Hopp 41d017
  	    if (draw_state == WL_FOLD - 1 && n_extra == 0)
Karsten Hopp 41d017
  	    {
Karsten Hopp 41d017
+ 		int fdc = compute_foldcolumn(wp, 0);
Karsten Hopp 41d017
+ 
Karsten Hopp 41d017
  		draw_state = WL_FOLD;
Karsten Hopp 41d017
! 		if (fdc > 0)
Karsten Hopp 41d017
  		{
Karsten Hopp 41d017
  		    /* Draw the 'foldcolumn'. */
Karsten Hopp 41d017
  		    fill_foldcolumn(extra, wp, FALSE, lnum);
Karsten Hopp 41d017
! 		    n_extra = fdc;
Karsten Hopp 41d017
  		    p_extra = extra;
Karsten Hopp 41d017
  		    p_extra[n_extra] = NUL;
Karsten Hopp 41d017
  		    c_extra = NUL;
Karsten Hopp 41d017
*** ../vim-7.4.602/src/version.c	2015-01-27 15:58:37.202395482 +0100
Karsten Hopp 41d017
--- src/version.c	2015-01-27 16:14:45.703878550 +0100
Karsten Hopp 41d017
***************
Karsten Hopp 41d017
*** 743,744 ****
Karsten Hopp 41d017
--- 743,746 ----
Karsten Hopp 41d017
  {   /* Add new patch number below this line */
Karsten Hopp 41d017
+ /**/
Karsten Hopp 41d017
+     603,
Karsten Hopp 41d017
  /**/
Karsten Hopp 41d017
Karsten Hopp 41d017
-- 
Karsten Hopp 41d017
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 41d017
129. You cancel your newspaper subscription.
Karsten Hopp 41d017
Karsten Hopp 41d017
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 41d017
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 41d017
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 41d017
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///