Blame SOURCES/7.4.338

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.338
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.338
22c937
Problem:    Cannot wrap lines taking indent into account.
22c937
Solution:   Add the 'breakindent' option. (many authors, final improvements by
22c937
	    Christian Brabandt)
22c937
Files:	    runtime/doc/eval.txt, runtime/doc/options.txt, runtime/optwin.vim,
22c937
	    src/buffer.c, src/charset.c, src/edit.c, src/ex_getln.c,
22c937
	    src/getchar.c, src/misc1.c, src/misc2.c, src/ops.c, src/option.c,
22c937
	    src/option.h, src/proto/charset.pro, src/proto/misc1.pro,
22c937
	    src/proto/option.pro, src/screen.c, src/structs.h,
22c937
	    src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
22c937
	    src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
22c937
	    src/testdir/Make_vms.mms, src/testdir/Makefile,
22c937
	    src/testdir/test_breakindent.in, src/testdir/test_breakindent.ok,
22c937
	    src/ui.c
22c937
22c937
22c937
*** ../vim-7.4.337/runtime/doc/eval.txt	2014-06-17 17:48:21.768628007 +0200
22c937
--- runtime/doc/eval.txt	2014-06-25 12:57:00.986115765 +0200
22c937
***************
22c937
*** 6639,6646 ****
22c937
  keymap			Compiled with 'keymap' support.
22c937
  langmap			Compiled with 'langmap' support.
22c937
  libcall			Compiled with |libcall()| support.
22c937
! linebreak		Compiled with 'linebreak', 'breakat' and 'showbreak'
22c937
! 			support.
22c937
  lispindent		Compiled with support for lisp indenting.
22c937
  listcmds		Compiled with commands for the buffer list |:files|
22c937
  			and the argument list |arglist|.
22c937
--- 6651,6658 ----
22c937
  keymap			Compiled with 'keymap' support.
22c937
  langmap			Compiled with 'langmap' support.
22c937
  libcall			Compiled with |libcall()| support.
22c937
! linebreak		Compiled with 'linebreak', 'breakat', 'showbreak' and
22c937
! 			'breakindent' support.
22c937
  lispindent		Compiled with support for lisp indenting.
22c937
  listcmds		Compiled with commands for the buffer list |:files|
22c937
  			and the argument list |arglist|.
22c937
*** ../vim-7.4.337/runtime/doc/options.txt	2014-06-17 17:48:21.768628007 +0200
22c937
--- runtime/doc/options.txt	2014-06-25 12:57:00.986115765 +0200
22c937
***************
22c937
*** 1200,1205 ****
22c937
--- 1200,1237 ----
22c937
  	break if 'linebreak' is on.  Only works for ASCII and also for 8-bit
22c937
  	characters when 'encoding' is an 8-bit encoding.
22c937
  
22c937
+ 						*'breakindent'* *'bri'*
22c937
+ 'breakindent' 'bri'	boolean (default off)
22c937
+ 			local to window
22c937
+ 			{not in Vi}
22c937
+ 			{not available when compiled without the |+linebreak|
22c937
+ 			feature}
22c937
+ 	Every wrapped line will continue visually indented (same amount of
22c937
+ 	space as the beginning of that line), thus preserving horizontal blocks
22c937
+ 	of text.
22c937
+ 
22c937
+ 						*'breakindentopt'* *'briopt'*
22c937
+ 'breakindentopt' 'briopt' string (default empty)
22c937
+ 			local to window
22c937
+ 			{not in Vi}
22c937
+ 			{not available when compiled without the |+linebreak|
22c937
+ 			feature}
22c937
+ 	Settings for 'breakindent'. It can consist of the following optional
22c937
+ 	items and must be seperated by a comma:
22c937
+ 		min:{n}	    Minimum text width that will be kept after
22c937
+ 			    applying 'breakindent', even if the resulting
22c937
+ 			    text should normally be narrower. This prevents
22c937
+ 			    text indented almost to the right window border
22c937
+ 			    occupying lot of vertical space when broken.
22c937
+ 		shift:{n}   After applying 'breakindent', wrapped line
22c937
+ 			    beginning will be shift by given number of
22c937
+ 			    characters. It permits dynamic French paragraph
22c937
+ 			    indentation (negative) or emphasizing the line
22c937
+ 			    continuation (positive).
22c937
+ 		sbr	    Display the 'showbreak' value before applying the 
22c937
+ 			    additional indent.
22c937
+ 	The default value for min is 20 and shift is 0.
22c937
+ 
22c937
  						*'browsedir'* *'bsdir'*
22c937
  'browsedir' 'bsdir'	string	(default: "last")
22c937
  			global
22c937
*** ../vim-7.4.337/runtime/optwin.vim	2014-04-01 12:26:40.241157964 +0200
22c937
--- runtime/optwin.vim	2014-06-25 12:57:00.990115765 +0200
22c937
***************
22c937
*** 324,329 ****
22c937
--- 324,335 ----
22c937
  call append("$", "linebreak\twrap long lines at a character in 'breakat'")
22c937
  call append("$", "\t(local to window)")
22c937
  call <SID>BinOptionL("lbr")
22c937
+ call append("$", "breakindent\tpreserve indentation in wrapped text")
22c937
+ call append("$", "\t(local to window)")
22c937
+ call <SID>BinOptionL("bri")
22c937
+ call append("$", "breakindentopt\tadjust breakindent behaviour")
22c937
+ call append("$", "\t(local to window)")
22c937
+ call <SID>OptionL("briopt")
22c937
  call append("$", "breakat\twhich characters might cause a line break")
22c937
  call <SID>OptionG("brk", &brk)
22c937
  call append("$", "showbreak\tstring to put before wrapped screen lines")
22c937
*** ../vim-7.4.337/src/charset.c	2014-03-23 15:12:29.911264336 +0100
22c937
--- src/charset.c	2014-06-25 13:23:05.842174966 +0200
22c937
***************
22c937
*** 867,875 ****
22c937
      char_u	*s;
22c937
  {
22c937
      colnr_T	col = startcol;
22c937
  
22c937
      while (*s != NUL)
22c937
! 	col += lbr_chartabsize_adv(&s, col);
22c937
      return (int)col;
22c937
  }
22c937
  
22c937
--- 867,876 ----
22c937
      char_u	*s;
22c937
  {
22c937
      colnr_T	col = startcol;
22c937
+     char_u	*line = s; /* pointer to start of line, for breakindent */
22c937
  
22c937
      while (*s != NUL)
22c937
! 	col += lbr_chartabsize_adv(line, &s, col);
22c937
      return (int)col;
22c937
  }
22c937
  
22c937
***************
22c937
*** 877,892 ****
22c937
   * Like linetabsize(), but for a given window instead of the current one.
22c937
   */
22c937
      int
22c937
! win_linetabsize(wp, p, len)
22c937
      win_T	*wp;
22c937
!     char_u	*p;
22c937
      colnr_T	len;
22c937
  {
22c937
      colnr_T	col = 0;
22c937
      char_u	*s;
22c937
  
22c937
!     for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s))
22c937
! 	col += win_lbr_chartabsize(wp, s, col, NULL);
22c937
      return (int)col;
22c937
  }
22c937
  
22c937
--- 878,894 ----
22c937
   * Like linetabsize(), but for a given window instead of the current one.
22c937
   */
22c937
      int
22c937
! win_linetabsize(wp, line, len)
22c937
      win_T	*wp;
22c937
!     char_u	*line;
22c937
      colnr_T	len;
22c937
  {
22c937
      colnr_T	col = 0;
22c937
      char_u	*s;
22c937
  
22c937
!     for (s = line; *s != NUL && (len == MAXCOL || s < line + len);
22c937
! 								mb_ptr_adv(s))
22c937
! 	col += win_lbr_chartabsize(wp, line, s, col, NULL);
22c937
      return (int)col;
22c937
  }
22c937
  
22c937
***************
22c937
*** 1021,1032 ****
22c937
   * like chartabsize(), but also check for line breaks on the screen
22c937
   */
22c937
      int
22c937
! lbr_chartabsize(s, col)
22c937
      unsigned char	*s;
22c937
      colnr_T		col;
22c937
  {
22c937
  #ifdef FEAT_LINEBREAK
22c937
!     if (!curwin->w_p_lbr && *p_sbr == NUL)
22c937
      {
22c937
  #endif
22c937
  #ifdef FEAT_MBYTE
22c937
--- 1023,1035 ----
22c937
   * like chartabsize(), but also check for line breaks on the screen
22c937
   */
22c937
      int
22c937
! lbr_chartabsize(line, s, col)
22c937
!     char_u		*line; /* start of the line */
22c937
      unsigned char	*s;
22c937
      colnr_T		col;
22c937
  {
22c937
  #ifdef FEAT_LINEBREAK
22c937
!     if (!curwin->w_p_lbr && *p_sbr == NUL && !curwin->w_p_bri)
22c937
      {
22c937
  #endif
22c937
  #ifdef FEAT_MBYTE
22c937
***************
22c937
*** 1036,1042 ****
22c937
  	RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
22c937
  #ifdef FEAT_LINEBREAK
22c937
      }
22c937
!     return win_lbr_chartabsize(curwin, s, col, NULL);
22c937
  #endif
22c937
  }
22c937
  
22c937
--- 1039,1045 ----
22c937
  	RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
22c937
  #ifdef FEAT_LINEBREAK
22c937
      }
22c937
!     return win_lbr_chartabsize(curwin, line == NULL ? s : line, s, col, NULL);
22c937
  #endif
22c937
  }
22c937
  
22c937
***************
22c937
*** 1044,1056 ****
22c937
   * Call lbr_chartabsize() and advance the pointer.
22c937
   */
22c937
      int
22c937
! lbr_chartabsize_adv(s, col)
22c937
      char_u	**s;
22c937
      colnr_T	col;
22c937
  {
22c937
      int		retval;
22c937
  
22c937
!     retval = lbr_chartabsize(*s, col);
22c937
      mb_ptr_adv(*s);
22c937
      return retval;
22c937
  }
22c937
--- 1047,1060 ----
22c937
   * Call lbr_chartabsize() and advance the pointer.
22c937
   */
22c937
      int
22c937
! lbr_chartabsize_adv(line, s, col)
22c937
!     char_u	*line; /* start of the line */
22c937
      char_u	**s;
22c937
      colnr_T	col;
22c937
  {
22c937
      int		retval;
22c937
  
22c937
!     retval = lbr_chartabsize(line, *s, col);
22c937
      mb_ptr_adv(*s);
22c937
      return retval;
22c937
  }
22c937
***************
22c937
*** 1063,1070 ****
22c937
   * value, init to 0 before calling.
22c937
   */
22c937
      int
22c937
! win_lbr_chartabsize(wp, s, col, headp)
22c937
      win_T	*wp;
22c937
      char_u	*s;
22c937
      colnr_T	col;
22c937
      int		*headp UNUSED;
22c937
--- 1067,1075 ----
22c937
   * value, init to 0 before calling.
22c937
   */
22c937
      int
22c937
! win_lbr_chartabsize(wp, line, s, col, headp)
22c937
      win_T	*wp;
22c937
+     char_u	*line; /* start of the line */
22c937
      char_u	*s;
22c937
      colnr_T	col;
22c937
      int		*headp UNUSED;
22c937
***************
22c937
*** 1086,1094 ****
22c937
      int		n;
22c937
  
22c937
      /*
22c937
!      * No 'linebreak' and 'showbreak': return quickly.
22c937
       */
22c937
!     if (!wp->w_p_lbr && *p_sbr == NUL)
22c937
  #endif
22c937
      {
22c937
  #ifdef FEAT_MBYTE
22c937
--- 1091,1099 ----
22c937
      int		n;
22c937
  
22c937
      /*
22c937
!      * No 'linebreak', 'showbreak' and 'breakindent': return quickly.
22c937
       */
22c937
!     if (!wp->w_p_lbr && !wp->w_p_bri && *p_sbr == NUL)
22c937
  #endif
22c937
      {
22c937
  #ifdef FEAT_MBYTE
22c937
***************
22c937
*** 1163,1173 ****
22c937
  # endif
22c937
  
22c937
      /*
22c937
!      * May have to add something for 'showbreak' string at start of line
22c937
       * Set *headp to the size of what we add.
22c937
       */
22c937
      added = 0;
22c937
!     if (*p_sbr != NUL && wp->w_p_wrap && col != 0)
22c937
      {
22c937
  	numberextra = win_col_off(wp);
22c937
  	col += numberextra + mb_added;
22c937
--- 1168,1179 ----
22c937
  # endif
22c937
  
22c937
      /*
22c937
!      * May have to add something for 'breakindent' and/or 'showbreak'
22c937
!      * string at start of line.
22c937
       * Set *headp to the size of what we add.
22c937
       */
22c937
      added = 0;
22c937
!     if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
22c937
      {
22c937
  	numberextra = win_col_off(wp);
22c937
  	col += numberextra + mb_added;
22c937
***************
22c937
*** 1180,1186 ****
22c937
  	}
22c937
  	if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
22c937
  	{
22c937
! 	    added = vim_strsize(p_sbr);
22c937
  	    if (tab_corr)
22c937
  		size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
22c937
  	    else
22c937
--- 1186,1197 ----
22c937
  	}
22c937
  	if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
22c937
  	{
22c937
! 	    added = 0;
22c937
! 	    if (*p_sbr != NUL)
22c937
! 		added += vim_strsize(p_sbr);
22c937
! 	    if (wp->w_p_bri)
22c937
! 		added += get_breakindent_win(wp, line);
22c937
! 
22c937
  	    if (tab_corr)
22c937
  		size += (added / wp->w_buffer->b_p_ts) * wp->w_buffer->b_p_ts;
22c937
  	    else
22c937
***************
22c937
*** 1274,1286 ****
22c937
      colnr_T	vcol;
22c937
      char_u	*ptr;		/* points to current char */
22c937
      char_u	*posptr;	/* points to char at pos->col */
22c937
      int		incr;
22c937
      int		head;
22c937
      int		ts = wp->w_buffer->b_p_ts;
22c937
      int		c;
22c937
  
22c937
      vcol = 0;
22c937
!     ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
22c937
      if (pos->col == MAXCOL)
22c937
  	posptr = NULL;  /* continue until the NUL */
22c937
      else
22c937
--- 1285,1298 ----
22c937
      colnr_T	vcol;
22c937
      char_u	*ptr;		/* points to current char */
22c937
      char_u	*posptr;	/* points to char at pos->col */
22c937
+     char_u	*line;		/* start of the line */
22c937
      int		incr;
22c937
      int		head;
22c937
      int		ts = wp->w_buffer->b_p_ts;
22c937
      int		c;
22c937
  
22c937
      vcol = 0;
22c937
!     line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
22c937
      if (pos->col == MAXCOL)
22c937
  	posptr = NULL;  /* continue until the NUL */
22c937
      else
22c937
***************
22c937
*** 1288,1299 ****
22c937
  
22c937
      /*
22c937
       * This function is used very often, do some speed optimizations.
22c937
!      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
22c937
       * Also use this when 'list' is set but tabs take their normal size.
22c937
       */
22c937
      if ((!wp->w_p_list || lcs_tab1 != NUL)
22c937
  #ifdef FEAT_LINEBREAK
22c937
! 	    && !wp->w_p_lbr && *p_sbr == NUL
22c937
  #endif
22c937
         )
22c937
      {
22c937
--- 1300,1312 ----
22c937
  
22c937
      /*
22c937
       * This function is used very often, do some speed optimizations.
22c937
!      * When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
22c937
!      * use a simple loop.
22c937
       * Also use this when 'list' is set but tabs take their normal size.
22c937
       */
22c937
      if ((!wp->w_p_list || lcs_tab1 != NUL)
22c937
  #ifdef FEAT_LINEBREAK
22c937
! 	    && !wp->w_p_lbr && *p_sbr == NUL && !wp->w_p_bri
22c937
  #endif
22c937
         )
22c937
      {
22c937
***************
22c937
*** 1355,1361 ****
22c937
  	{
22c937
  	    /* A tab gets expanded, depending on the current column */
22c937
  	    head = 0;
22c937
! 	    incr = win_lbr_chartabsize(wp, ptr, vcol, &head;;
22c937
  	    /* make sure we don't go past the end of the line */
22c937
  	    if (*ptr == NUL)
22c937
  	    {
22c937
--- 1368,1374 ----
22c937
  	{
22c937
  	    /* A tab gets expanded, depending on the current column */
22c937
  	    head = 0;
22c937
! 	    incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head;;
22c937
  	    /* make sure we don't go past the end of the line */
22c937
  	    if (*ptr == NUL)
22c937
  	    {
22c937
*** ../vim-7.4.337/src/edit.c	2014-05-28 21:40:47.092329130 +0200
22c937
--- src/edit.c	2014-06-25 13:16:43.278160493 +0200
22c937
***************
22c937
*** 1956,1962 ****
22c937
  	    else
22c937
  #endif
22c937
  		++new_cursor_col;
22c937
! 	    vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
22c937
  	}
22c937
  	vcol = last_vcol;
22c937
  
22c937
--- 1956,1962 ----
22c937
  	    else
22c937
  #endif
22c937
  		++new_cursor_col;
22c937
! 	    vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
22c937
  	}
22c937
  	vcol = last_vcol;
22c937
  
22c937
***************
22c937
*** 7126,7134 ****
22c937
  	for (;;)
22c937
  	{
22c937
  	    coladvance(v - width);
22c937
! 	    /* getviscol() is slow, skip it when 'showbreak' is empty and
22c937
! 	     * there are no multi-byte characters */
22c937
! 	    if ((*p_sbr == NUL
22c937
  #  ifdef FEAT_MBYTE
22c937
  			&& !has_mbyte
22c937
  #  endif
22c937
--- 7126,7135 ----
22c937
  	for (;;)
22c937
  	{
22c937
  	    coladvance(v - width);
22c937
! 	    /* getviscol() is slow, skip it when 'showbreak' is empty,
22c937
! 	     * 'breakindent' is not set and there are no multi-byte
22c937
! 	     * characters */
22c937
! 	    if ((*p_sbr == NUL && !curwin->w_p_bri
22c937
  #  ifdef FEAT_MBYTE
22c937
  			&& !has_mbyte
22c937
  #  endif
22c937
***************
22c937
*** 9758,9768 ****
22c937
  	getvcol(curwin, &fpos, &vcol, NULL, NULL);
22c937
  	getvcol(curwin, cursor, &want_vcol, NULL, NULL);
22c937
  
22c937
! 	/* Use as many TABs as possible.  Beware of 'showbreak' and
22c937
! 	 * 'linebreak' adding extra virtual columns. */
22c937
  	while (vim_iswhite(*ptr))
22c937
  	{
22c937
! 	    i = lbr_chartabsize((char_u *)"\t", vcol);
22c937
  	    if (vcol + i > want_vcol)
22c937
  		break;
22c937
  	    if (*ptr != TAB)
22c937
--- 9759,9769 ----
22c937
  	getvcol(curwin, &fpos, &vcol, NULL, NULL);
22c937
  	getvcol(curwin, cursor, &want_vcol, NULL, NULL);
22c937
  
22c937
! 	/* Use as many TABs as possible.  Beware of 'breakindent', 'showbreak'
22c937
! 	 * and 'linebreak' adding extra virtual columns. */
22c937
  	while (vim_iswhite(*ptr))
22c937
  	{
22c937
! 	    i = lbr_chartabsize(NULL, (char_u *)"\t", vcol);
22c937
  	    if (vcol + i > want_vcol)
22c937
  		break;
22c937
  	    if (*ptr != TAB)
22c937
***************
22c937
*** 9784,9794 ****
22c937
  	if (change_col >= 0)
22c937
  	{
22c937
  	    int repl_off = 0;
22c937
  
22c937
  	    /* Skip over the spaces we need. */
22c937
  	    while (vcol < want_vcol && *ptr == ' ')
22c937
  	    {
22c937
! 		vcol += lbr_chartabsize(ptr, vcol);
22c937
  		++ptr;
22c937
  		++repl_off;
22c937
  	    }
22c937
--- 9785,9796 ----
22c937
  	if (change_col >= 0)
22c937
  	{
22c937
  	    int repl_off = 0;
22c937
+ 	    char_u *line = ptr;
22c937
  
22c937
  	    /* Skip over the spaces we need. */
22c937
  	    while (vcol < want_vcol && *ptr == ' ')
22c937
  	    {
22c937
! 		vcol += lbr_chartabsize(line, ptr, vcol);
22c937
  		++ptr;
22c937
  		++repl_off;
22c937
  	    }
22c937
***************
22c937
*** 10029,10034 ****
22c937
--- 10031,10037 ----
22c937
      int	    c;
22c937
      int	    temp;
22c937
      char_u  *ptr, *prev_ptr;
22c937
+     char_u  *line;
22c937
  
22c937
      if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
22c937
      {
22c937
***************
22c937
*** 10038,10050 ****
22c937
  
22c937
      /* try to advance to the cursor column */
22c937
      temp = 0;
22c937
!     ptr = ml_get(lnum);
22c937
      prev_ptr = ptr;
22c937
      validate_virtcol();
22c937
      while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
22c937
      {
22c937
  	prev_ptr = ptr;
22c937
! 	temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
22c937
      }
22c937
      if ((colnr_T)temp > curwin->w_virtcol)
22c937
  	ptr = prev_ptr;
22c937
--- 10041,10053 ----
22c937
  
22c937
      /* try to advance to the cursor column */
22c937
      temp = 0;
22c937
!     line = ptr = ml_get(lnum);
22c937
      prev_ptr = ptr;
22c937
      validate_virtcol();
22c937
      while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL)
22c937
      {
22c937
  	prev_ptr = ptr;
22c937
! 	temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp);
22c937
      }
22c937
      if ((colnr_T)temp > curwin->w_virtcol)
22c937
  	ptr = prev_ptr;
22c937
*** ../vim-7.4.337/src/ex_getln.c	2014-06-25 12:26:42.230046959 +0200
22c937
--- src/ex_getln.c	2014-06-25 12:57:00.998115765 +0200
22c937
***************
22c937
*** 2302,2311 ****
22c937
  
22c937
  		p = (char_u *)line_ga.ga_data;
22c937
  		p[line_ga.ga_len] = NUL;
22c937
! 		indent = get_indent_str(p, 8);
22c937
  		indent += sw - indent % sw;
22c937
  add_indent:
22c937
! 		while (get_indent_str(p, 8) < indent)
22c937
  		{
22c937
  		    char_u *s = skipwhite(p);
22c937
  
22c937
--- 2302,2311 ----
22c937
  
22c937
  		p = (char_u *)line_ga.ga_data;
22c937
  		p[line_ga.ga_len] = NUL;
22c937
! 		indent = get_indent_str(p, 8, FALSE);
22c937
  		indent += sw - indent % sw;
22c937
  add_indent:
22c937
! 		while (get_indent_str(p, 8, FALSE) < indent)
22c937
  		{
22c937
  		    char_u *s = skipwhite(p);
22c937
  
22c937
***************
22c937
*** 2357,2367 ****
22c937
  		else
22c937
  		{
22c937
  		    p[line_ga.ga_len] = NUL;
22c937
! 		    indent = get_indent_str(p, 8);
22c937
  		    --indent;
22c937
  		    indent -= indent % get_sw_value(curbuf);
22c937
  		}
22c937
! 		while (get_indent_str(p, 8) > indent)
22c937
  		{
22c937
  		    char_u *s = skipwhite(p);
22c937
  
22c937
--- 2357,2367 ----
22c937
  		else
22c937
  		{
22c937
  		    p[line_ga.ga_len] = NUL;
22c937
! 		    indent = get_indent_str(p, 8, FALSE);
22c937
  		    --indent;
22c937
  		    indent -= indent % get_sw_value(curbuf);
22c937
  		}
22c937
! 		while (get_indent_str(p, 8, FALSE) > indent)
22c937
  		{
22c937
  		    char_u *s = skipwhite(p);
22c937
  
22c937
*** ../vim-7.4.337/src/getchar.c	2014-05-22 18:59:54.510169240 +0200
22c937
--- src/getchar.c	2014-06-25 13:16:53.946160896 +0200
22c937
***************
22c937
*** 2675,2681 ****
22c937
  				{
22c937
  				    if (!vim_iswhite(ptr[col]))
22c937
  					curwin->w_wcol = vcol;
22c937
! 				    vcol += lbr_chartabsize(ptr + col,
22c937
  							       (colnr_T)vcol);
22c937
  #ifdef FEAT_MBYTE
22c937
  				    if (has_mbyte)
22c937
--- 2675,2681 ----
22c937
  				{
22c937
  				    if (!vim_iswhite(ptr[col]))
22c937
  					curwin->w_wcol = vcol;
22c937
! 				    vcol += lbr_chartabsize(ptr, ptr + col,
22c937
  							       (colnr_T)vcol);
22c937
  #ifdef FEAT_MBYTE
22c937
  				    if (has_mbyte)
22c937
*** ../vim-7.4.337/src/misc1.c	2014-05-22 14:00:12.698534712 +0200
22c937
--- src/misc1.c	2014-06-25 13:39:43.598212712 +0200
22c937
***************
22c937
*** 32,38 ****
22c937
      int
22c937
  get_indent()
22c937
  {
22c937
!     return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts);
22c937
  }
22c937
  
22c937
  /*
22c937
--- 32,38 ----
22c937
      int
22c937
  get_indent()
22c937
  {
22c937
!     return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);
22c937
  }
22c937
  
22c937
  /*
22c937
***************
22c937
*** 42,48 ****
22c937
  get_indent_lnum(lnum)
22c937
      linenr_T	lnum;
22c937
  {
22c937
!     return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts);
22c937
  }
22c937
  
22c937
  #if defined(FEAT_FOLDING) || defined(PROTO)
22c937
--- 42,48 ----
22c937
  get_indent_lnum(lnum)
22c937
      linenr_T	lnum;
22c937
  {
22c937
!     return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);
22c937
  }
22c937
  
22c937
  #if defined(FEAT_FOLDING) || defined(PROTO)
22c937
***************
22c937
*** 55,61 ****
22c937
      buf_T	*buf;
22c937
      linenr_T	lnum;
22c937
  {
22c937
!     return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts);
22c937
  }
22c937
  #endif
22c937
  
22c937
--- 55,61 ----
22c937
      buf_T	*buf;
22c937
      linenr_T	lnum;
22c937
  {
22c937
!     return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
22c937
  }
22c937
  #endif
22c937
  
22c937
***************
22c937
*** 64,79 ****
22c937
   * 'tabstop' at "ts"
22c937
   */
22c937
      int
22c937
! get_indent_str(ptr, ts)
22c937
      char_u	*ptr;
22c937
      int		ts;
22c937
  {
22c937
      int		count = 0;
22c937
  
22c937
      for ( ; *ptr; ++ptr)
22c937
      {
22c937
! 	if (*ptr == TAB)    /* count a tab for what it is worth */
22c937
! 	    count += ts - (count % ts);
22c937
  	else if (*ptr == ' ')
22c937
  	    ++count;		/* count a space for one */
22c937
  	else
22c937
--- 64,86 ----
22c937
   * 'tabstop' at "ts"
22c937
   */
22c937
      int
22c937
! get_indent_str(ptr, ts, list)
22c937
      char_u	*ptr;
22c937
      int		ts;
22c937
+     int		list; /* if TRUE, count only screen size for tabs */
22c937
  {
22c937
      int		count = 0;
22c937
  
22c937
      for ( ; *ptr; ++ptr)
22c937
      {
22c937
! 	if (*ptr == TAB)
22c937
! 	{
22c937
! 	    if (!list || lcs_tab1)    /* count a tab for what it is worth */
22c937
! 		count += ts - (count % ts);
22c937
! 	    else
22c937
! 	/* in list mode, when tab is not set, count screen char width for Tab: ^I */
22c937
! 		count += ptr2cells(ptr);
22c937
! 	}
22c937
  	else if (*ptr == ' ')
22c937
  	    ++count;		/* count a space for one */
22c937
  	else
22c937
***************
22c937
*** 476,481 ****
22c937
--- 483,540 ----
22c937
      return (int)col;
22c937
  }
22c937
  
22c937
+ #if defined(FEAT_LINEBREAK) || defined(PROTO)
22c937
+ /*
22c937
+  * Return appropriate space number for breakindent, taking influencing
22c937
+  * parameters into account. Window must be specified, since it is not
22c937
+  * necessarily always the current one.
22c937
+  */
22c937
+     int
22c937
+ get_breakindent_win(wp, line)
22c937
+     win_T	*wp;
22c937
+     char_u	*line; /* start of the line */
22c937
+ {
22c937
+     static int	    prev_indent = 0;  /* cached indent value */
22c937
+     static long	    prev_ts     = 0L; /* cached tabstop value */
22c937
+     static char_u   *prev_line = NULL; /* cached pointer to line */
22c937
+     int		    bri = 0;
22c937
+     /* window width minus window margin space, i.e. what rests for text */
22c937
+     const int	    eff_wwidth = W_WIDTH(wp)
22c937
+ 			    - ((wp->w_p_nu || wp->w_p_rnu)
22c937
+ 				&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
22c937
+ 						? number_width(wp) + 1 : 0);
22c937
+ 
22c937
+     /* used cached indent, unless pointer or 'tabstop' changed */
22c937
+     if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts)
22c937
+     {
22c937
+ 	prev_line = line;
22c937
+ 	prev_ts = wp->w_buffer->b_p_ts;
22c937
+ 	prev_indent = get_indent_str(line,
22c937
+ 		  (int)wp->w_buffer->b_p_ts, wp->w_p_list) + wp->w_p_brishift;
22c937
+     }
22c937
+ 
22c937
+     /* indent minus the length of the showbreak string */
22c937
+     bri = prev_indent;
22c937
+     if (wp->w_p_brisbr)
22c937
+ 	bri -= vim_strsize(p_sbr);
22c937
+ 
22c937
+     /* Add offset for number column, if 'n' is in 'cpoptions' */
22c937
+     bri += win_col_off2(wp);
22c937
+ 
22c937
+     /* never indent past left window margin */
22c937
+     if (bri < 0)
22c937
+ 	bri = 0;
22c937
+     /* always leave at least bri_min characters on the left,
22c937
+      * if text width is sufficient */
22c937
+     else if (bri > eff_wwidth - wp->w_p_brimin)
22c937
+ 	bri = (eff_wwidth - wp->w_p_brimin < 0)
22c937
+ 			    ? 0 : eff_wwidth - wp->w_p_brimin;
22c937
+ 
22c937
+     return bri;
22c937
+ }
22c937
+ #endif
22c937
+ 
22c937
+ 
22c937
  #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
22c937
  
22c937
  static int cin_is_cinword __ARGS((char_u *line));
22c937
***************
22c937
*** 678,684 ****
22c937
  	/*
22c937
  	 * count white space on current line
22c937
  	 */
22c937
! 	newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts);
22c937
  	if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
22c937
  	    newindent = second_line_indent; /* for ^^D command in insert mode */
22c937
  
22c937
--- 737,743 ----
22c937
  	/*
22c937
  	 * count white space on current line
22c937
  	 */
22c937
! 	newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts, FALSE);
22c937
  	if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
22c937
  	    newindent = second_line_indent; /* for ^^D command in insert mode */
22c937
  
22c937
***************
22c937
*** 1201,1207 ****
22c937
  					|| do_si
22c937
  #endif
22c937
  							   )
22c937
! 			newindent = get_indent_str(leader, (int)curbuf->b_p_ts);
22c937
  
22c937
  		    /* Add the indent offset */
22c937
  		    if (newindent + off < 0)
22c937
--- 1260,1266 ----
22c937
  					|| do_si
22c937
  #endif
22c937
  							   )
22c937
! 			newindent = get_indent_str(leader, (int)curbuf->b_p_ts, FALSE);
22c937
  
22c937
  		    /* Add the indent offset */
22c937
  		    if (newindent + off < 0)
22c937
***************
22c937
*** 1994,1999 ****
22c937
--- 2053,2059 ----
22c937
      char_u	*s;
22c937
      int		lines = 0;
22c937
      int		width;
22c937
+     char_u	*line;
22c937
  
22c937
  #ifdef FEAT_DIFF
22c937
      /* Check for filler lines above this buffer line.  When folded the result
22c937
***************
22c937
*** 2009,2020 ****
22c937
  	return lines + 1;
22c937
  #endif
22c937
  
22c937
!     s = ml_get_buf(wp->w_buffer, lnum, FALSE);
22c937
  
22c937
      col = 0;
22c937
      while (*s != NUL && --column >= 0)
22c937
      {
22c937
! 	col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL);
22c937
  	mb_ptr_adv(s);
22c937
      }
22c937
  
22c937
--- 2069,2080 ----
22c937
  	return lines + 1;
22c937
  #endif
22c937
  
22c937
!     line = s = ml_get_buf(wp->w_buffer, lnum, FALSE);
22c937
  
22c937
      col = 0;
22c937
      while (*s != NUL && --column >= 0)
22c937
      {
22c937
! 	col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL);
22c937
  	mb_ptr_adv(s);
22c937
      }
22c937
  
22c937
***************
22c937
*** 2026,2032 ****
22c937
       * 'ts') -- webb.
22c937
       */
22c937
      if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
22c937
! 	col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL) - 1;
22c937
  
22c937
      /*
22c937
       * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
22c937
--- 2086,2092 ----
22c937
       * 'ts') -- webb.
22c937
       */
22c937
      if (*s == TAB && (State & NORMAL) && (!wp->w_p_list || lcs_tab1))
22c937
! 	col += win_lbr_chartabsize(wp, line, s, (colnr_T)col, NULL) - 1;
22c937
  
22c937
      /*
22c937
       * Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
22c937
***************
22c937
*** 9002,9011 ****
22c937
  		amount = 2;
22c937
  	    else
22c937
  	    {
22c937
  		amount = 0;
22c937
  		while (*that && col)
22c937
  		{
22c937
! 		    amount += lbr_chartabsize_adv(&that, (colnr_T)amount);
22c937
  		    col--;
22c937
  		}
22c937
  
22c937
--- 9062,9073 ----
22c937
  		amount = 2;
22c937
  	    else
22c937
  	    {
22c937
+ 		char_u *line = that;
22c937
+ 
22c937
  		amount = 0;
22c937
  		while (*that && col)
22c937
  		{
22c937
! 		    amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);
22c937
  		    col--;
22c937
  		}
22c937
  
22c937
***************
22c937
*** 9028,9034 ****
22c937
  
22c937
  		    while (vim_iswhite(*that))
22c937
  		    {
22c937
! 			amount += lbr_chartabsize(that, (colnr_T)amount);
22c937
  			++that;
22c937
  		    }
22c937
  
22c937
--- 9090,9096 ----
22c937
  
22c937
  		    while (vim_iswhite(*that))
22c937
  		    {
22c937
! 			amount += lbr_chartabsize(line, that, (colnr_T)amount);
22c937
  			++that;
22c937
  		    }
22c937
  
22c937
***************
22c937
*** 9066,9080 ****
22c937
  							       && !quotecount)
22c937
  				    --parencount;
22c937
  				if (*that == '\\' && *(that+1) != NUL)
22c937
! 				    amount += lbr_chartabsize_adv(&that,
22c937
! 							     (colnr_T)amount);
22c937
! 				amount += lbr_chartabsize_adv(&that,
22c937
! 							     (colnr_T)amount);
22c937
  			    }
22c937
  			}
22c937
  			while (vim_iswhite(*that))
22c937
  			{
22c937
! 			    amount += lbr_chartabsize(that, (colnr_T)amount);
22c937
  			    that++;
22c937
  			}
22c937
  			if (!*that || *that == ';')
22c937
--- 9128,9143 ----
22c937
  							       && !quotecount)
22c937
  				    --parencount;
22c937
  				if (*that == '\\' && *(that+1) != NUL)
22c937
! 				    amount += lbr_chartabsize_adv(
22c937
! 						line, &that, (colnr_T)amount);
22c937
! 				amount += lbr_chartabsize_adv(
22c937
! 						line, &that, (colnr_T)amount);
22c937
  			    }
22c937
  			}
22c937
  			while (vim_iswhite(*that))
22c937
  			{
22c937
! 			    amount += lbr_chartabsize(
22c937
! 						 line, that, (colnr_T)amount);
22c937
  			    that++;
22c937
  			}
22c937
  			if (!*that || *that == ';')
22c937
*** ../vim-7.4.337/src/misc2.c	2014-05-07 18:35:25.669216052 +0200
22c937
--- src/misc2.c	2014-06-25 13:21:18.474170904 +0200
22c937
***************
22c937
*** 201,210 ****
22c937
  	{
22c937
  	    /* Count a tab for what it's worth (if list mode not on) */
22c937
  #ifdef FEAT_LINEBREAK
22c937
! 	    csize = win_lbr_chartabsize(curwin, ptr, col, &head;;
22c937
  	    mb_ptr_adv(ptr);
22c937
  #else
22c937
! 	    csize = lbr_chartabsize_adv(&ptr, col);
22c937
  #endif
22c937
  	    col += csize;
22c937
  	}
22c937
--- 201,210 ----
22c937
  	{
22c937
  	    /* Count a tab for what it's worth (if list mode not on) */
22c937
  #ifdef FEAT_LINEBREAK
22c937
! 	    csize = win_lbr_chartabsize(curwin, line, ptr, col, &head;;
22c937
  	    mb_ptr_adv(ptr);
22c937
  #else
22c937
! 	    csize = lbr_chartabsize_adv(line, &ptr, col);
22c937
  #endif
22c937
  	    col += csize;
22c937
  	}
22c937
***************
22c937
*** 2156,2162 ****
22c937
      }
22c937
  }
22c937
  
22c937
! #if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264)
22c937
  /*
22c937
   * Append the text in "gap" below the cursor line and clear "gap".
22c937
   */
22c937
--- 2156,2163 ----
22c937
      }
22c937
  }
22c937
  
22c937
! #if (defined(UNIX) && !defined(USE_SYSTEM)) || defined(WIN3264) \
22c937
! 	|| defined(PROTO)
22c937
  /*
22c937
   * Append the text in "gap" below the cursor line and clear "gap".
22c937
   */
22c937
*** ../vim-7.4.337/src/ops.c	2014-06-17 18:16:08.420691059 +0200
22c937
--- src/ops.c	2014-06-25 13:18:27.082164420 +0200
22c937
***************
22c937
*** 420,426 ****
22c937
  	}
22c937
  	for ( ; vim_iswhite(*bd.textstart); )
22c937
  	{
22c937
! 	    incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
22c937
  	    total += incr;
22c937
  	    bd.start_vcol += incr;
22c937
  	}
22c937
--- 420,428 ----
22c937
  	}
22c937
  	for ( ; vim_iswhite(*bd.textstart); )
22c937
  	{
22c937
! 	    /* TODO: is passing bd.textstart for start of the line OK? */
22c937
! 	    incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart,
22c937
! 						    (colnr_T)(bd.start_vcol));
22c937
  	    total += incr;
22c937
  	    bd.start_vcol += incr;
22c937
  	}
22c937
***************
22c937
*** 480,486 ****
22c937
  
22c937
  	while (vim_iswhite(*non_white))
22c937
  	{
22c937
! 	    incr = lbr_chartabsize_adv(&non_white, non_white_col);
22c937
  	    non_white_col += incr;
22c937
  	}
22c937
  
22c937
--- 482,488 ----
22c937
  
22c937
  	while (vim_iswhite(*non_white))
22c937
  	{
22c937
! 	    incr = lbr_chartabsize_adv(bd.textstart, &non_white, non_white_col);
22c937
  	    non_white_col += incr;
22c937
  	}
22c937
  
22c937
***************
22c937
*** 505,511 ****
22c937
  	    verbatim_copy_width -= bd.start_char_vcols;
22c937
  	while (verbatim_copy_width < destination_col)
22c937
  	{
22c937
! 	    incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
22c937
  	    if (verbatim_copy_width + incr > destination_col)
22c937
  		break;
22c937
  	    verbatim_copy_width += incr;
22c937
--- 507,517 ----
22c937
  	    verbatim_copy_width -= bd.start_char_vcols;
22c937
  	while (verbatim_copy_width < destination_col)
22c937
  	{
22c937
! 	    char_u *line = verbatim_copy_end;
22c937
! 
22c937
! 	    /* TODO: is passing verbatim_copy_end for start of the line OK? */
22c937
! 	    incr = lbr_chartabsize(line, verbatim_copy_end,
22c937
! 							 verbatim_copy_width);
22c937
  	    if (verbatim_copy_width + incr > destination_col)
22c937
  		break;
22c937
  	    verbatim_copy_width += incr;
22c937
***************
22c937
*** 3617,3623 ****
22c937
  	    for (ptr = oldp; vcol < col && *ptr; )
22c937
  	    {
22c937
  		/* Count a tab for what it's worth (if list mode not on) */
22c937
! 		incr = lbr_chartabsize_adv(&ptr, (colnr_T)vcol);
22c937
  		vcol += incr;
22c937
  	    }
22c937
  	    bd.textcol = (colnr_T)(ptr - oldp);
22c937
--- 3623,3629 ----
22c937
  	    for (ptr = oldp; vcol < col && *ptr; )
22c937
  	    {
22c937
  		/* Count a tab for what it's worth (if list mode not on) */
22c937
! 		incr = lbr_chartabsize_adv(oldp, &ptr, (colnr_T)vcol);
22c937
  		vcol += incr;
22c937
  	    }
22c937
  	    bd.textcol = (colnr_T)(ptr - oldp);
22c937
***************
22c937
*** 3651,3657 ****
22c937
  	    /* calculate number of spaces required to fill right side of block*/
22c937
  	    spaces = y_width + 1;
22c937
  	    for (j = 0; j < yanklen; j++)
22c937
! 		spaces -= lbr_chartabsize(&y_array[i][j], 0);
22c937
  	    if (spaces < 0)
22c937
  		spaces = 0;
22c937
  
22c937
--- 3657,3663 ----
22c937
  	    /* calculate number of spaces required to fill right side of block*/
22c937
  	    spaces = y_width + 1;
22c937
  	    for (j = 0; j < yanklen; j++)
22c937
! 		spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
22c937
  	    if (spaces < 0)
22c937
  		spaces = 0;
22c937
  
22c937
***************
22c937
*** 5203,5209 ****
22c937
      while (bdp->start_vcol < oap->start_vcol && *pstart)
22c937
      {
22c937
  	/* Count a tab for what it's worth (if list mode not on) */
22c937
! 	incr = lbr_chartabsize(pstart, (colnr_T)bdp->start_vcol);
22c937
  	bdp->start_vcol += incr;
22c937
  #ifdef FEAT_VISUALEXTRA
22c937
  	if (vim_iswhite(*pstart))
22c937
--- 5209,5215 ----
22c937
      while (bdp->start_vcol < oap->start_vcol && *pstart)
22c937
      {
22c937
  	/* Count a tab for what it's worth (if list mode not on) */
22c937
! 	incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol);
22c937
  	bdp->start_vcol += incr;
22c937
  #ifdef FEAT_VISUALEXTRA
22c937
  	if (vim_iswhite(*pstart))
22c937
***************
22c937
*** 5272,5278 ****
22c937
  	    {
22c937
  		/* Count a tab for what it's worth (if list mode not on) */
22c937
  		prev_pend = pend;
22c937
! 		incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol);
22c937
  		bdp->end_vcol += incr;
22c937
  	    }
22c937
  	    if (bdp->end_vcol <= oap->end_vcol
22c937
--- 5278,5287 ----
22c937
  	    {
22c937
  		/* Count a tab for what it's worth (if list mode not on) */
22c937
  		prev_pend = pend;
22c937
! 		/* TODO: is passing prev_pend for start of the line OK?
22c937
! 		 * perhaps it should be "line". */
22c937
! 		incr = lbr_chartabsize_adv(prev_pend, &pend,
22c937
! 						      (colnr_T)bdp->end_vcol);
22c937
  		bdp->end_vcol += incr;
22c937
  	    }
22c937
  	    if (bdp->end_vcol <= oap->end_vcol
22c937
***************
22c937
*** 6882,6888 ****
22c937
  	    validate_virtcol();
22c937
  	    col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
22c937
  		    (int)curwin->w_virtcol + 1);
22c937
! 	    col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
22c937
  
22c937
  	    if (char_count_cursor == byte_count_cursor
22c937
  		    && char_count == byte_count)
22c937
--- 6891,6898 ----
22c937
  	    validate_virtcol();
22c937
  	    col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
22c937
  		    (int)curwin->w_virtcol + 1);
22c937
! 	    col_print(buf2, sizeof(buf2), (int)STRLEN(p),
22c937
! 				linetabsize(p));
22c937
  
22c937
  	    if (char_count_cursor == byte_count_cursor
22c937
  		    && char_count == byte_count)
22c937
*** ../vim-7.4.337/src/option.c	2014-06-25 11:48:40.733960646 +0200
22c937
--- src/option.c	2014-06-25 14:31:41.630330672 +0200
22c937
***************
22c937
*** 188,193 ****
22c937
--- 188,197 ----
22c937
  #ifdef FEAT_ARABIC
22c937
  # define PV_ARAB	OPT_WIN(WV_ARAB)
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ # define PV_BRI		OPT_WIN(WV_BRI)
22c937
+ # define PV_BRIOPT	OPT_WIN(WV_BRIOPT)
22c937
+ #endif
22c937
  #ifdef FEAT_DIFF
22c937
  # define PV_DIFF	OPT_WIN(WV_DIFF)
22c937
  #endif
22c937
***************
22c937
*** 648,653 ****
22c937
--- 652,675 ----
22c937
  			    {(char_u *)0L, (char_u *)0L}
22c937
  #endif
22c937
  			    SCRIPTID_INIT},
22c937
+     {"breakindent",   "bri",  P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ 			    (char_u *)VAR_WIN, PV_BRI,
22c937
+ 			    {(char_u *)FALSE, (char_u *)0L}
22c937
+ #else
22c937
+ 			    (char_u *)NULL, PV_NONE,
22c937
+ 			    {(char_u *)0L, (char_u *)0L}
22c937
+ #endif
22c937
+ 			    SCRIPTID_INIT},
22c937
+     {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_COMMA|P_NODUP,
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ 			    (char_u *)VAR_WIN, PV_BRIOPT,
22c937
+ 			    {(char_u *)"", (char_u *)NULL}
22c937
+ #else
22c937
+ 			    (char_u *)NULL, PV_NONE,
22c937
+ 			    {(char_u *)"", (char_u *)NULL}
22c937
+ #endif
22c937
+ 			    SCRIPTID_INIT},
22c937
      {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
22c937
  #ifdef FEAT_BROWSE
22c937
  			    (char_u *)&p_bsdir, PV_NONE,
22c937
***************
22c937
*** 5256,5261 ****
22c937
--- 5278,5286 ----
22c937
      /* set cedit_key */
22c937
      (void)check_cedit();
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     briopt_check();
22c937
+ #endif
22c937
  }
22c937
  
22c937
  /*
22c937
***************
22c937
*** 5709,5714 ****
22c937
--- 5734,5747 ----
22c937
  		     *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
22c937
  	    errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
22c937
      }
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     /* 'breakindentopt' */
22c937
+     else if (varp == &curwin->w_p_briopt)
22c937
+     {
22c937
+ 	if (briopt_check() == FAIL)
22c937
+ 	    errmsg = e_invarg;
22c937
+     }
22c937
+ #endif
22c937
  
22c937
      /*
22c937
       * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
22c937
***************
22c937
*** 10018,10023 ****
22c937
--- 10051,10058 ----
22c937
  	case PV_WRAP:	return (char_u *)&(curwin->w_p_wrap);
22c937
  #ifdef FEAT_LINEBREAK
22c937
  	case PV_LBR:	return (char_u *)&(curwin->w_p_lbr);
22c937
+ 	case PV_BRI:	return (char_u *)&(curwin->w_p_bri);
22c937
+ 	case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
22c937
  #endif
22c937
  #ifdef FEAT_SCROLLBIND
22c937
  	case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
22c937
***************
22c937
*** 10207,10212 ****
22c937
--- 10242,10249 ----
22c937
  #endif
22c937
  #ifdef FEAT_LINEBREAK
22c937
      to->wo_lbr = from->wo_lbr;
22c937
+     to->wo_bri = from->wo_bri;
22c937
+     to->wo_briopt = vim_strsave(from->wo_briopt);
22c937
  #endif
22c937
  #ifdef FEAT_SCROLLBIND
22c937
      to->wo_scb = from->wo_scb;
22c937
***************
22c937
*** 10294,10299 ****
22c937
--- 10331,10339 ----
22c937
  #ifdef FEAT_CONCEAL
22c937
      check_string_option(&wop->wo_cocu);
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     check_string_option(&wop->wo_briopt);
22c937
+ #endif
22c937
  }
22c937
  
22c937
  /*
22c937
***************
22c937
*** 10313,10318 ****
22c937
--- 10353,10361 ----
22c937
  # endif
22c937
      clear_string_option(&wop->wo_fmr);
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     clear_string_option(&wop->wo_briopt);
22c937
+ #endif
22c937
  #ifdef FEAT_RIGHTLEFT
22c937
      clear_string_option(&wop->wo_rlc);
22c937
  #endif
22c937
***************
22c937
*** 11927,11929 ****
22c937
--- 11970,12018 ----
22c937
  	    ++ptr;
22c937
      }
22c937
  }
22c937
+ 
22c937
+ #if defined(FEAT_LINEBREAK) || defined(PROTO)
22c937
+ /*
22c937
+  * This is called when 'breakindentopt' is changed and when a window is
22c937
+  * initialized.
22c937
+  */
22c937
+     int
22c937
+ briopt_check()
22c937
+ {
22c937
+     char_u	*p;
22c937
+     int		bri_shift = 0;
22c937
+     long	bri_min = 20;
22c937
+     int		bri_sbr = FALSE;
22c937
+ 
22c937
+     p = curwin->w_p_briopt;
22c937
+     while (*p != NUL)
22c937
+     {
22c937
+ 	if (STRNCMP(p, "shift:", 6) == 0
22c937
+ 		 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
22c937
+ 	{
22c937
+ 	    p += 6;
22c937
+ 	    bri_shift = getdigits(&p);
22c937
+ 	}
22c937
+ 	else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
22c937
+ 	{
22c937
+ 	    p += 4;
22c937
+ 	    bri_min = getdigits(&p);
22c937
+ 	}
22c937
+ 	else if (STRNCMP(p, "sbr", 3) == 0)
22c937
+ 	{
22c937
+ 	    p += 3;
22c937
+ 	    bri_sbr = TRUE;
22c937
+ 	}
22c937
+ 	if (*p != ',' && *p != NUL)
22c937
+ 	    return FAIL;
22c937
+ 	if (*p == ',')
22c937
+ 	    ++p;
22c937
+     }
22c937
+ 
22c937
+     curwin->w_p_brishift = bri_shift;
22c937
+     curwin->w_p_brimin   = bri_min;
22c937
+     curwin->w_p_brisbr   = bri_sbr;
22c937
+ 
22c937
+     return OK;
22c937
+ }
22c937
+ #endif
22c937
*** ../vim-7.4.337/src/option.h	2014-05-28 21:40:47.092329130 +0200
22c937
--- src/option.h	2014-06-25 12:57:01.002115765 +0200
22c937
***************
22c937
*** 1052,1057 ****
22c937
--- 1052,1061 ----
22c937
  #ifdef FEAT_CURSORBIND
22c937
      , WV_CRBIND
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     , WV_BRI
22c937
+     , WV_BRIOPT
22c937
+ #endif
22c937
  #ifdef FEAT_DIFF
22c937
      , WV_DIFF
22c937
  #endif
22c937
*** ../vim-7.4.337/src/proto/charset.pro	2013-08-10 13:37:07.000000000 +0200
22c937
--- src/proto/charset.pro	2014-06-25 13:22:32.934173721 +0200
22c937
***************
22c937
*** 16,22 ****
22c937
  int chartabsize __ARGS((char_u *p, colnr_T col));
22c937
  int linetabsize __ARGS((char_u *s));
22c937
  int linetabsize_col __ARGS((int startcol, char_u *s));
22c937
! int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len));
22c937
  int vim_isIDc __ARGS((int c));
22c937
  int vim_iswordc __ARGS((int c));
22c937
  int vim_iswordc_buf __ARGS((int c, buf_T *buf));
22c937
--- 16,22 ----
22c937
  int chartabsize __ARGS((char_u *p, colnr_T col));
22c937
  int linetabsize __ARGS((char_u *s));
22c937
  int linetabsize_col __ARGS((int startcol, char_u *s));
22c937
! int win_linetabsize __ARGS((win_T *wp, char_u *line, colnr_T len));
22c937
  int vim_isIDc __ARGS((int c));
22c937
  int vim_iswordc __ARGS((int c));
22c937
  int vim_iswordc_buf __ARGS((int c, buf_T *buf));
22c937
***************
22c937
*** 26,34 ****
22c937
  int vim_isfilec_or_wc __ARGS((int c));
22c937
  int vim_isprintc __ARGS((int c));
22c937
  int vim_isprintc_strict __ARGS((int c));
22c937
! int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
22c937
! int lbr_chartabsize_adv __ARGS((char_u **s, colnr_T col));
22c937
! int win_lbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
22c937
  int in_win_border __ARGS((win_T *wp, colnr_T vcol));
22c937
  void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
22c937
  colnr_T getvcol_nolist __ARGS((pos_T *posp));
22c937
--- 26,34 ----
22c937
  int vim_isfilec_or_wc __ARGS((int c));
22c937
  int vim_isprintc __ARGS((int c));
22c937
  int vim_isprintc_strict __ARGS((int c));
22c937
! int lbr_chartabsize __ARGS((char_u *line, unsigned char *s, colnr_T col));
22c937
! int lbr_chartabsize_adv __ARGS((char_u *line, char_u **s, colnr_T col));
22c937
! int win_lbr_chartabsize __ARGS((win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp));
22c937
  int in_win_border __ARGS((win_T *wp, colnr_T vcol));
22c937
  void getvcol __ARGS((win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end));
22c937
  colnr_T getvcol_nolist __ARGS((pos_T *posp));
22c937
*** ../vim-7.4.337/src/proto/misc1.pro	2014-05-07 15:10:17.661108310 +0200
22c937
--- src/proto/misc1.pro	2014-06-25 12:57:01.002115765 +0200
22c937
***************
22c937
*** 2,10 ****
22c937
  int get_indent __ARGS((void));
22c937
  int get_indent_lnum __ARGS((linenr_T lnum));
22c937
  int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
22c937
! int get_indent_str __ARGS((char_u *ptr, int ts));
22c937
  int set_indent __ARGS((int size, int flags));
22c937
  int get_number_indent __ARGS((linenr_T lnum));
22c937
  int open_line __ARGS((int dir, int flags, int second_line_indent));
22c937
  int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int include_space));
22c937
  int get_last_leader_offset __ARGS((char_u *line, char_u **flags));
22c937
--- 2,11 ----
22c937
  int get_indent __ARGS((void));
22c937
  int get_indent_lnum __ARGS((linenr_T lnum));
22c937
  int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
22c937
! int get_indent_str __ARGS((char_u *ptr, int ts, int list));
22c937
  int set_indent __ARGS((int size, int flags));
22c937
  int get_number_indent __ARGS((linenr_T lnum));
22c937
+ int get_breakindent_win __ARGS((win_T *wp, char_u *ptr));
22c937
  int open_line __ARGS((int dir, int flags, int second_line_indent));
22c937
  int get_leader_len __ARGS((char_u *line, char_u **flags, int backward, int include_space));
22c937
  int get_last_leader_offset __ARGS((char_u *line, char_u **flags));
22c937
*** ../vim-7.4.337/src/proto/option.pro	2014-01-14 16:54:53.000000000 +0100
22c937
--- src/proto/option.pro	2014-06-25 14:16:04.882295233 +0200
22c937
***************
22c937
*** 63,66 ****
22c937
--- 63,67 ----
22c937
  long get_sw_value __ARGS((buf_T *buf));
22c937
  long get_sts_value __ARGS((void));
22c937
  void find_mps_values __ARGS((int *initc, int *findc, int *backwards, int switchit));
22c937
+ int briopt_check __ARGS((void));
22c937
  /* vim: set ft=c : */
22c937
*** ../vim-7.4.337/src/screen.c	2014-06-18 21:20:07.232377308 +0200
22c937
--- src/screen.c	2014-06-25 13:43:39.930221653 +0200
22c937
***************
22c937
*** 2962,2971 ****
22c937
  # define WL_SIGN	WL_FOLD		/* column for signs */
22c937
  #endif
22c937
  #define WL_NR		WL_SIGN + 1	/* line number */
22c937
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
22c937
! # define WL_SBR		WL_NR + 1	/* 'showbreak' or 'diff' */
22c937
  #else
22c937
! # define WL_SBR		WL_NR
22c937
  #endif
22c937
  #define WL_LINE		WL_SBR + 1	/* text in the line */
22c937
      int		draw_state = WL_START;	/* what to draw next */
22c937
--- 2962,2976 ----
22c937
  # define WL_SIGN	WL_FOLD		/* column for signs */
22c937
  #endif
22c937
  #define WL_NR		WL_SIGN + 1	/* line number */
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ # define WL_BRI		WL_NR + 1	/* 'breakindent' */
22c937
+ #else
22c937
+ # define WL_BRI		WL_NR
22c937
+ #endif
22c937
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
22c937
! # define WL_SBR		WL_BRI + 1	/* 'showbreak' or 'diff' */
22c937
  #else
22c937
! # define WL_SBR		WL_BRI
22c937
  #endif
22c937
  #define WL_LINE		WL_SBR + 1	/* text in the line */
22c937
      int		draw_state = WL_START;	/* what to draw next */
22c937
***************
22c937
*** 3301,3307 ****
22c937
  #endif
22c937
  	while (vcol < v && *ptr != NUL)
22c937
  	{
22c937
! 	    c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL);
22c937
  	    vcol += c;
22c937
  #ifdef FEAT_MBYTE
22c937
  	    prev_ptr = ptr;
22c937
--- 3306,3312 ----
22c937
  #endif
22c937
  	while (vcol < v && *ptr != NUL)
22c937
  	{
22c937
! 	    c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
22c937
  	    vcol += c;
22c937
  #ifdef FEAT_MBYTE
22c937
  	    prev_ptr = ptr;
22c937
***************
22c937
*** 3670,3675 ****
22c937
--- 3675,3718 ----
22c937
  		}
22c937
  	    }
22c937
  
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+ 	    if (wp->w_p_brisbr && draw_state == WL_BRI - 1
22c937
+ 					     && n_extra == 0 && *p_sbr != NUL)
22c937
+ 		/* draw indent after showbreak value */
22c937
+ 		draw_state = WL_BRI;
22c937
+ 	    else if (wp->w_p_brisbr && draw_state == WL_SBR && n_extra == 0)
22c937
+ 		/* After the showbreak, draw the breakindent */
22c937
+ 		draw_state = WL_BRI - 1;
22c937
+ 
22c937
+ 	    /* draw 'breakindent': indent wrapped text accordingly */
22c937
+ 	    if (draw_state == WL_BRI - 1 && n_extra == 0)
22c937
+ 	    {
22c937
+ 		draw_state = WL_BRI;
22c937
+ # ifdef FEAT_DIFF
22c937
+ # endif
22c937
+ 		if (wp->w_p_bri && n_extra == 0 && row != startrow
22c937
+ #ifdef FEAT_DIFF
22c937
+ 			&& filler_lines == 0
22c937
+ #endif
22c937
+ 		   )
22c937
+ 		{
22c937
+ 		    char_attr = 0; /* was: hl_attr(HLF_AT); */
22c937
+ #ifdef FEAT_DIFF
22c937
+ 		    if (diff_hlf != (hlf_T)0)
22c937
+ 			char_attr = hl_attr(diff_hlf);
22c937
+ #endif
22c937
+ 		    p_extra = NUL;
22c937
+ 		    c_extra = ' ';
22c937
+ 		    n_extra = get_breakindent_win(wp,
22c937
+ 				       ml_get_buf(wp->w_buffer, lnum, FALSE));
22c937
+ 		    /* Correct end of highlighted area for 'breakindent',
22c937
+ 		     * required when 'linebreak' is also set. */
22c937
+ 		    if (tocol == vcol)
22c937
+ 			tocol += n_extra;
22c937
+ 		}
22c937
+ 	    }
22c937
+ #endif
22c937
+ 
22c937
  #if defined(FEAT_LINEBREAK) || defined(FEAT_DIFF)
22c937
  	    if (draw_state == WL_SBR - 1 && n_extra == 0)
22c937
  	    {
22c937
***************
22c937
*** 4382,4392 ****
22c937
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
22c937
  							     && !wp->w_p_list)
22c937
  		{
22c937
! 		    n_extra = win_lbr_chartabsize(wp, ptr - (
22c937
  # ifdef FEAT_MBYTE
22c937
  				has_mbyte ? mb_l :
22c937
  # endif
22c937
! 				1), (colnr_T)vcol, NULL) - 1;
22c937
  		    c_extra = ' ';
22c937
  		    if (vim_iswhite(c))
22c937
  		    {
22c937
--- 4425,4438 ----
22c937
  		if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
22c937
  							     && !wp->w_p_list)
22c937
  		{
22c937
! 		    char_u *p = ptr - (
22c937
  # ifdef FEAT_MBYTE
22c937
  				has_mbyte ? mb_l :
22c937
  # endif
22c937
! 				1);
22c937
! 		    /* TODO: is passing p for start of the line OK? */
22c937
! 		    n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol,
22c937
! 								    NULL) - 1;
22c937
  		    c_extra = ' ';
22c937
  		    if (vim_iswhite(c))
22c937
  		    {
22c937
***************
22c937
*** 8916,8923 ****
22c937
  	{
22c937
  	    if (noinvcurs)
22c937
  		screen_stop_highlight();
22c937
! 	    if (row == screen_cur_row && (col > screen_cur_col) &&
22c937
! 								*T_CRI != NUL)
22c937
  		term_cursor_right(col - screen_cur_col);
22c937
  	    else
22c937
  		term_windgoto(row, col);
22c937
--- 8962,8969 ----
22c937
  	{
22c937
  	    if (noinvcurs)
22c937
  		screen_stop_highlight();
22c937
! 	    if (row == screen_cur_row && (col > screen_cur_col)
22c937
! 							     && *T_CRI != NUL)
22c937
  		term_cursor_right(col - screen_cur_col);
22c937
  	    else
22c937
  		term_windgoto(row, col);
22c937
*** ../vim-7.4.337/src/structs.h	2014-06-17 17:48:21.784628008 +0200
22c937
--- src/structs.h	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 134,139 ****
22c937
--- 134,145 ----
22c937
      int		wo_arab;
22c937
  # define w_p_arab w_onebuf_opt.wo_arab	/* 'arabic' */
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     int		wo_bri;
22c937
+ # define w_p_bri w_onebuf_opt.wo_bri	/* 'breakindent' */
22c937
+     char_u		*wo_briopt;
22c937
+ # define w_p_briopt w_onebuf_opt.wo_briopt /* 'breakindentopt' */
22c937
+ #endif
22c937
  #ifdef FEAT_DIFF
22c937
      int		wo_diff;
22c937
  # define w_p_diff w_onebuf_opt.wo_diff	/* 'diff' */
22c937
***************
22c937
*** 2189,2194 ****
22c937
--- 2195,2205 ----
22c937
  #ifdef FEAT_SYN_HL
22c937
      int		*w_p_cc_cols;	    /* array of columns to highlight or NULL */
22c937
  #endif
22c937
+ #ifdef FEAT_LINEBREAK
22c937
+     int		w_p_brimin;	    /* minimum width for breakindent */
22c937
+     int		w_p_brishift;	    /* additional shift for breakindent */
22c937
+     int		w_p_brisbr;	    /* sbr in 'briopt' */
22c937
+ #endif
22c937
  
22c937
      /* transform a pointer to a "onebuf" option into a "allbuf" option */
22c937
  #define GLOBAL_WO(p)	((char *)p + sizeof(winopt_T))
22c937
*** ../vim-7.4.337/src/testdir/Make_amiga.mak	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Make_amiga.mak	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 37,42 ****
22c937
--- 37,43 ----
22c937
  		test99.out test100.out test101.out test102.out test103.out \
22c937
  		test104.out test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
+ 		test_breakindent.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
***************
22c937
*** 163,167 ****
22c937
--- 164,169 ----
22c937
  test106.out: test106.in
22c937
  test107.out: test107.in
22c937
  test_autoformat_join.out: test_autoformat_join.in
22c937
+ test_breakindent.out: test_breakindent.in
22c937
  test_eval.out: test_eval.in
22c937
  test_options.out: test_options.in
22c937
*** ../vim-7.4.337/src/testdir/Make_dos.mak	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Make_dos.mak	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 36,41 ****
22c937
--- 36,42 ----
22c937
  		test100.out test101.out test102.out test103.out test104.out \
22c937
  		test105.out test106.out  test107.out\
22c937
  		test_autoformat_join.out \
22c937
+ 		test_breakindent.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.337/src/testdir/Make_ming.mak	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Make_ming.mak	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 56,61 ****
22c937
--- 56,62 ----
22c937
  		test100.out test101.out test102.out test103.out test104.out \
22c937
  		test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
+ 		test_breakindent.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.337/src/testdir/Make_os2.mak	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Make_os2.mak	2014-06-25 12:59:45.774121999 +0200
22c937
***************
22c937
*** 39,44 ****
22c937
--- 39,45 ----
22c937
  		test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
  		test_eval.out \
22c937
+ 		test_breakindent.out \
22c937
  		test_options.out
22c937
  
22c937
  .SUFFIXES: .in .out
22c937
*** ../vim-7.4.337/src/testdir/Make_vms.mms	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Make_vms.mms	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 97,102 ****
22c937
--- 97,103 ----
22c937
  	 test100.out test101.out test103.out test104.out \
22c937
  	 test105.out test106.out test107.out \
22c937
  	 test_autoformat_join.out \
22c937
+ 	 test_breakindent.out \
22c937
  	 test_eval.out \
22c937
  	 test_options.out
22c937
  
22c937
*** ../vim-7.4.337/src/testdir/Makefile	2014-05-29 11:47:19.804773758 +0200
22c937
--- src/testdir/Makefile	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 34,39 ****
22c937
--- 34,40 ----
22c937
  		test99.out test100.out test101.out test102.out test103.out \
22c937
  		test104.out test105.out test106.out test107.out \
22c937
  		test_autoformat_join.out \
22c937
+ 		test_breakindent.out \
22c937
  		test_eval.out \
22c937
  		test_options.out
22c937
  
22c937
*** ../vim-7.4.337/src/testdir/test_breakindent.in	2014-06-25 14:36:28.690341532 +0200
22c937
--- src/testdir/test_breakindent.in	2014-06-25 14:26:00.994317785 +0200
22c937
***************
22c937
*** 0 ****
22c937
--- 1,79 ----
22c937
+ Test for breakindent
22c937
+ 
22c937
+ STARTTEST
22c937
+ :so small.vim
22c937
+ :if !exists("+breakindent") | e! test.ok | w! test.out | qa! | endif
22c937
+ :10new|:vsp|:vert resize 20
22c937
+ :put =\"\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP\"
22c937
+ :set ts=4 sw=4 sts=4 breakindent
22c937
+ :fu! ScreenChar(width)
22c937
+ :	let c=''
22c937
+ :	for i in range(1,a:width)
22c937
+ :		let c.=nr2char(screenchar(line('.'), i))
22c937
+ :	endfor
22c937
+ :       let c.="\n"
22c937
+ :	for i in range(1,a:width)
22c937
+ :		let c.=nr2char(screenchar(line('.')+1, i))
22c937
+ :	endfor
22c937
+ :       let c.="\n"
22c937
+ :	for i in range(1,a:width)
22c937
+ :		let c.=nr2char(screenchar(line('.')+2, i))
22c937
+ :	endfor
22c937
+ :	return c
22c937
+ :endfu
22c937
+ :fu DoRecordScreen()
22c937
+ :	wincmd l
22c937
+ :	$put =printf(\"\n%s\", g:test)
22c937
+ :	$put =g:line1
22c937
+ :	wincmd p
22c937
+ :endfu
22c937
+ :let g:test="Test 1: Simple breakindent"
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test="Test 2: Simple breakindent + sbr=>>"
22c937
+ :set sbr=>>
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 3: Simple breakindent + briopt:sbr"
22c937
+ :set briopt=sbr,min:0 sbr=++
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test ="Test 4: Simple breakindent + min width: 18"
22c937
+ :set sbr= briopt=min:18
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test =" Test 5: Simple breakindent + shift by 2"
22c937
+ :set briopt=shift:2,min:0
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test=" Test 6: Simple breakindent + shift by -1"
22c937
+ :set briopt=shift:-1,min:0
22c937
+ :let line1=ScreenChar(8)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test=" Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr"
22c937
+ :set briopt=shift:1,sbr,min:0 nu sbr=? nuw=4
22c937
+ :let line1=ScreenChar(10)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test=" Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr"
22c937
+ :set briopt=shift:1,sbr,min:0 nu sbr=# list
22c937
+ :let line1=ScreenChar(10)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test=" Test 9: breakindent + shift by +1 + 'nu' + sbr=# list"
22c937
+ :set briopt-=sbr
22c937
+ :let line1=ScreenChar(10)
22c937
+ :call DoRecordScreen()
22c937
+ :let g:test=" Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n"
22c937
+ :set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
22c937
+ :let line1=ScreenChar(10)
22c937
+ :call DoRecordScreen()
22c937
+ :wincmd p
22c937
+ :let g:test="\n Test 11: strdisplaywidth when breakindent is on"
22c937
+ :set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
22c937
+ :let text=getline(2) "skip leading tab when calculating text width
22c937
+ :let width = strlen(text[1:])+indent(2)*4+strlen(&sbr)*3 " text wraps 3 times
22c937
+ :$put =g:test
22c937
+ :$put =printf(\"strdisplaywidth: %d == calculated: %d\", strdisplaywidth(text), width)
22c937
+ :%w! test.out
22c937
+ :qa!
22c937
+ ENDTEST
22c937
+ dummy text
22c937
*** ../vim-7.4.337/src/testdir/test_breakindent.ok	2014-06-25 14:36:28.698341532 +0200
22c937
--- src/testdir/test_breakindent.ok	2014-06-25 12:57:01.006115766 +0200
22c937
***************
22c937
*** 0 ****
22c937
--- 1,55 ----
22c937
+ 
22c937
+ 	abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP
22c937
+ 
22c937
+ Test 1: Simple breakindent
22c937
+     abcd
22c937
+     qrst
22c937
+     GHIJ
22c937
+ 
22c937
+ Test 2: Simple breakindent + sbr=>>
22c937
+     abcd
22c937
+     >>qr
22c937
+     >>EF
22c937
+ 
22c937
+ Test 3: Simple breakindent + briopt:sbr
22c937
+     abcd
22c937
+ ++  qrst
22c937
+ ++  GHIJ
22c937
+ 
22c937
+ Test 4: Simple breakindent + min width: 18
22c937
+     abcd
22c937
+   qrstuv
22c937
+   IJKLMN
22c937
+ 
22c937
+  Test 5: Simple breakindent + shift by 2
22c937
+     abcd
22c937
+       qr
22c937
+       EF
22c937
+ 
22c937
+  Test 6: Simple breakindent + shift by -1
22c937
+     abcd
22c937
+    qrstu
22c937
+    HIJKL
22c937
+ 
22c937
+  Test 7: breakindent + shift by +1 + nu + sbr=? briopt:sbr
22c937
+   2     ab
22c937
+ ?        m
22c937
+ ?        x
22c937
+ 
22c937
+  Test 8: breakindent + shift:1 + nu + sbr=# list briopt:sbr
22c937
+   2 ^Iabcd
22c937
+ #      opq
22c937
+ #      BCD
22c937
+ 
22c937
+  Test 9: breakindent + shift by +1 + 'nu' + sbr=# list
22c937
+   2 ^Iabcd
22c937
+        #op
22c937
+        #AB
22c937
+ 
22c937
+  Test 10: breakindent + shift by +1 + 'nu' + sbr=~ cpo+=n
22c937
+   2     ab
22c937
+ ~       mn
22c937
+ ~       yz
22c937
+ 
22c937
+  Test 11: strdisplaywidth when breakindent is on
22c937
+ strdisplaywidth: 46 == calculated: 64
22c937
*** ../vim-7.4.337/src/ui.c	2014-06-12 13:28:26.771694851 +0200
22c937
--- src/ui.c	2014-06-25 13:22:20.218173240 +0200
22c937
***************
22c937
*** 3162,3176 ****
22c937
      /* try to advance to the specified column */
22c937
      int		count = 0;
22c937
      char_u	*ptr;
22c937
!     char_u	*start;
22c937
  
22c937
!     start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
22c937
      while (count < vcol && *ptr != NUL)
22c937
      {
22c937
! 	count += win_lbr_chartabsize(wp, ptr, count, NULL);
22c937
  	mb_ptr_adv(ptr);
22c937
      }
22c937
!     return (int)(ptr - start);
22c937
  }
22c937
  #endif
22c937
  
22c937
--- 3162,3176 ----
22c937
      /* try to advance to the specified column */
22c937
      int		count = 0;
22c937
      char_u	*ptr;
22c937
!     char_u	*line;
22c937
  
22c937
!     line = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
22c937
      while (count < vcol && *ptr != NUL)
22c937
      {
22c937
! 	count += win_lbr_chartabsize(wp, line, ptr, count, NULL);
22c937
  	mb_ptr_adv(ptr);
22c937
      }
22c937
!     return (int)(ptr - line);
22c937
  }
22c937
  #endif
22c937
  
22c937
*** ../vim-7.4.337/src/version.c	2014-06-25 12:26:42.230046959 +0200
22c937
--- src/version.c	2014-06-25 13:00:26.990123558 +0200
22c937
***************
22c937
*** 736,737 ****
22c937
--- 736,739 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     338,
22c937
  /**/
22c937
22c937
-- 
22c937
MORTICIAN:    Bring out your dead!
22c937
              [clang]
22c937
              Bring out your dead!
22c937
              [clang]
22c937
              Bring out your dead!
22c937
CUSTOMER:     Here's one -- nine pence.
22c937
DEAD PERSON:  I'm not dead!
22c937
                                  The Quest for the Holy Grail (Monty Python)
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///