On Mi, 25 Jun 2014, Bram Moolenaar wrote:

> Bram wrote:
> 
> > Christian wrote:
> > 
> > > Finally a new patch, here we go:
> 
> [...]
> 
> > Thanks, much better now.
> > 
> > Let me include it and make a few small improvements.  I'm sure we will
> > discover more problems once more people use the feature, I hope you will
> > fix these problems then!
> 
> I already found and fixed a few problems.
> 
> When starting Vim the default values for the 'briopt' option are not
> used.
> 
> The documentation says that the default for the minimum is 20, but the
> implementation uses a default of 0.  A default of 20 is much more
> useful, so let's use that.  I had to change the tests to compensate.
> Now we might as well make the default value empty.
> 
> I added TODO items in places where I did not understand the code, mainly
> failing to pass in the start of the line, thus computing indent on
> somewhere halfway a line.  If the pointer doesn't matter we better pass
> NULL, so it's clear we do not compute the indent.  If it does matter I
> suspect there are situations where the column is not computed correctly.
> 
> Please have a look at these added TODO items.

Attach patch fixes a few problems:

1) I think you are correct with the few TODO items. I have changed that 
to the correct line pointer.
2) small fix for the test (the strdisplay() was executed in the wrong 
window, hence the difference)
3) Changed default_value of briopt back to 'shift:0,min:20'. If you 
don't like that, feel free to skip that part.
4) do not cache the indent, as it seems to cause more problems, then it 
solves (see recent bug report here).

Best,
Christian
-- 
Wieso springen Blinde nicht mit dem Fallschirm?
Zitat aus "Money Train":
'Weil ihre Hunde eine panische Angst vorm Fliegen haben.'

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/misc1.c b/src/misc1.c
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -494,9 +494,6 @@ get_breakindent_win(wp, line)
     win_T	*wp;
     char_u	*line; /* start of the line */
 {
-    static int	    prev_indent = 0;  /* cached indent value */
-    static long	    prev_ts     = 0L; /* cached tabstop value */
-    static char_u   *prev_line = NULL; /* cached pointer to line */
     int		    bri = 0;
     /* window width minus window margin space, i.e. what rests for text */
     const int	    eff_wwidth = W_WIDTH(wp)
@@ -504,17 +501,9 @@ get_breakindent_win(wp, line)
 				&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
 						? number_width(wp) + 1 : 0);
 
-    /* used cached indent, unless pointer or 'tabstop' changed */
-    if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts)
-    {
-	prev_line = line;
-	prev_ts = wp->w_buffer->b_p_ts;
-	prev_indent = get_indent_str(line,
+    bri = get_indent_str(line,
 		  (int)wp->w_buffer->b_p_ts, wp->w_p_list) + wp->w_p_brishift;
-    }
-
-    /* indent minus the length of the showbreak string */
-    bri = prev_indent;
+
     if (wp->w_p_brisbr)
 	bri -= vim_strsize(p_sbr);
 
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -420,8 +420,7 @@ shift_block(oap, amount)
 	}
 	for ( ; vim_iswhite(*bd.textstart); )
 	{
-	    /* TODO: is passing bd.textstart for start of the line OK? */
-	    incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart,
+	    incr = lbr_chartabsize_adv(oldp, &bd.textstart,
 						    (colnr_T)(bd.start_vcol));
 	    total += incr;
 	    bd.start_vcol += incr;
@@ -482,7 +481,7 @@ shift_block(oap, amount)
 
 	while (vim_iswhite(*non_white))
 	{
-	    incr = lbr_chartabsize_adv(bd.textstart, &non_white, non_white_col);
+	    incr = lbr_chartabsize_adv(oldp, &non_white, non_white_col);
 	    non_white_col += incr;
 	}
 
@@ -507,10 +506,7 @@ shift_block(oap, amount)
 	    verbatim_copy_width -= bd.start_char_vcols;
 	while (verbatim_copy_width < destination_col)
 	{
-	    char_u *line = verbatim_copy_end;
-
-	    /* TODO: is passing verbatim_copy_end for start of the line OK? */
-	    incr = lbr_chartabsize(line, verbatim_copy_end,
+	    incr = lbr_chartabsize(oldp, verbatim_copy_end,
 							 verbatim_copy_width);
 	    if (verbatim_copy_width + incr > destination_col)
 		break;
diff --git a/src/option.c b/src/option.c
--- a/src/option.c
+++ b/src/option.c
@@ -664,7 +664,7 @@ static struct vimoption
     {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_COMMA|P_NODUP,
 #ifdef FEAT_LINEBREAK
 			    (char_u *)VAR_WIN, PV_BRIOPT,
-			    {(char_u *)"", (char_u *)NULL}
+			    {(char_u *)"shift:0,min:20", (char_u *)NULL}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)NULL}
@@ -11982,7 +11982,7 @@ briopt_check()
 {
     char_u	*p;
     int		bri_shift = 0;
-    long	bri_min = 20;
+    long	bri_min = 0;
     int		bri_sbr = FALSE;
 
     p = curwin->w_p_briopt;
diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -4430,8 +4430,7 @@ win_line(wp, lnum, startrow, endrow, noc
 				has_mbyte ? mb_l :
 # endif
 				1);
-		    /* TODO: is passing p for start of the line OK? */
-		    n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol,
+		    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
 								    NULL) - 1;
 		    c_extra = ' ';
 		    if (vim_iswhite(c))
diff --git a/src/testdir/test_breakindent.in b/src/testdir/test_breakindent.in
--- a/src/testdir/test_breakindent.in
+++ b/src/testdir/test_breakindent.in
@@ -66,7 +66,6 @@ STARTTEST
 :set cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0
 :let line1=ScreenChar(10)
 :call DoRecordScreen()
-:wincmd p
 :let g:test="\n Test 11: strdisplaywidth when breakindent is on"
 :set cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4
 :let text=getline(2) "skip leading tab when calculating text width

Raspunde prin e-mail lui