]> granicus.if.org Git - vim/commitdiff
patch 9.0.0746: breakindent test cases are commented out v9.0.0746
authorBram Moolenaar <Bram@vim.org>
Thu, 13 Oct 2022 20:54:28 +0000 (21:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 13 Oct 2022 20:54:28 +0000 (21:54 +0100)
Problem:    Breakindent test cases are commented out.
Solution:   Adjust expected result to slightly different behavior.  Correct
            computations for cursor position.

src/move.c
src/structs.h
src/testdir/test_breakindent.vim
src/version.c

index 995301e8d2e01f350017b06b5e36c1135ef870a3..3a2eb5df89b43c7014a4d6198c2a65e145ff6157 100644 (file)
@@ -1036,8 +1036,8 @@ curs_columns(
     int                off_left, off_right;
     int                n;
     int                p_lines;
-    int                width = 0;
-    int                textwidth;
+    int                width1;         // text width for first screen line
+    int                width2 = 0;     // text width for second and later screen line
     int                new_leftcol;
     colnr_T    startcol;
     colnr_T    endcol;
@@ -1087,8 +1087,8 @@ curs_columns(
      */
     curwin->w_wrow = curwin->w_cline_row;
 
-    textwidth = curwin->w_width - extra;
-    if (textwidth <= 0)
+    width1 = curwin->w_width - extra;
+    if (width1 <= 0)
     {
        // No room for text, put cursor in last char of window.
        // If not wrapping, the last non-empty line.
@@ -1100,13 +1100,20 @@ curs_columns(
     }
     else if (curwin->w_p_wrap && curwin->w_width != 0)
     {
-       width = textwidth + curwin_col_off2();
+       width2 = width1 + curwin_col_off2();
 
        // skip columns that are not visible
        if (curwin->w_cursor.lnum == curwin->w_topline
+               && curwin->w_skipcol > 0
                && curwin->w_wcol >= curwin->w_skipcol)
        {
-           curwin->w_wcol -= curwin->w_skipcol;
+           // w_skipcol excludes win_col_off().  Include it here, since w_wcol
+           // counts actual screen columns.
+           if (curwin->w_skipcol <= width1)
+               curwin->w_wcol -= curwin->w_width;
+           else
+               curwin->w_wcol -= curwin->w_width
+                              * (((curwin->w_skipcol - width1) / width2) + 1);
            did_sub_skipcol = TRUE;
        }
 
@@ -1114,8 +1121,8 @@ curs_columns(
        if (curwin->w_wcol >= curwin->w_width)
        {
            // this same formula is used in validate_cursor_col()
-           n = (curwin->w_wcol - curwin->w_width) / width + 1;
-           curwin->w_wcol -= n * width;
+           n = (curwin->w_wcol - curwin->w_width) / width2 + 1;
+           curwin->w_wcol -= n * width2;
            curwin->w_wrow += n;
 
 #ifdef FEAT_LINEBREAK
@@ -1170,8 +1177,8 @@ curs_columns(
 
            // When far off or not enough room on either side, put cursor in
            // middle of window.
-           if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
-               new_leftcol = curwin->w_wcol - extra - textwidth / 2;
+           if (p_ss == 0 || diff >= width1 / 2 || off_right >= off_left)
+               new_leftcol = curwin->w_wcol - extra - width1 / 2;
            else
            {
                if (diff < p_ss)
@@ -1223,7 +1230,7 @@ curs_columns(
                                                    - 1 >= curwin->w_height))
            && curwin->w_height != 0
            && curwin->w_cursor.lnum == curwin->w_topline
-           && width > 0
+           && width2 > 0
            && curwin->w_width != 0)
     {
        // Cursor past end of screen.  Happens with a single line that does
@@ -1233,7 +1240,7 @@ curs_columns(
        // 2: Less than 'scrolloff' lines below
        // 3: both of them
        extra = 0;
-       if (curwin->w_skipcol + so * width > curwin->w_virtcol)
+       if (curwin->w_skipcol + so * width2 > curwin->w_virtcol)
            extra = 1;
        // Compute last display line of the buffer line that we want at the
        // bottom of the window.
@@ -1244,13 +1251,13 @@ curs_columns(
            n = curwin->w_wrow + so;
        else
            n = p_lines;
-       if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width - so)
+       if ((colnr_T)n >= curwin->w_height + curwin->w_skipcol / width2 - so)
            extra += 2;
 
        if (extra == 3 || curwin->w_height <= so * 2)
        {
            // not enough room for 'scrolloff', put cursor in the middle
-           n = curwin->w_virtcol / width;
+           n = curwin->w_virtcol / width2;
            if (n > curwin->w_height / 2)
                n -= curwin->w_height / 2;
            else
@@ -1258,45 +1265,45 @@ curs_columns(
            // don't skip more than necessary
            if (n > p_lines - curwin->w_height + 1)
                n = p_lines - curwin->w_height + 1;
-           curwin->w_skipcol = n * width;
+           curwin->w_skipcol = n * width2;
        }
        else if (extra == 1)
        {
            // less than 'scrolloff' lines above, decrease skipcol
-           extra = (curwin->w_skipcol + so * width - curwin->w_virtcol
-                                    + width - 1) / width;
+           extra = (curwin->w_skipcol + so * width2 - curwin->w_virtcol
+                                    + width2 - 1) / width2;
            if (extra > 0)
            {
-               if ((colnr_T)(extra * width) > curwin->w_skipcol)
-                   extra = curwin->w_skipcol / width;
-               curwin->w_skipcol -= extra * width;
+               if ((colnr_T)(extra * width2) > curwin->w_skipcol)
+                   extra = curwin->w_skipcol / width2;
+               curwin->w_skipcol -= extra * width2;
            }
        }
        else if (extra == 2)
        {
            // less than 'scrolloff' lines below, increase skipcol
-           endcol = (n - curwin->w_height + 1) * width;
+           endcol = (n - curwin->w_height + 1) * width2;
            while (endcol > curwin->w_virtcol)
-               endcol -= width;
+               endcol -= width2;
            if (endcol > curwin->w_skipcol)
                curwin->w_skipcol = endcol;
        }
 
        // adjust w_wrow for the changed w_skipcol
        if (did_sub_skipcol)
-           curwin->w_wrow -= (curwin->w_skipcol - prev_skipcol) / width;
+           curwin->w_wrow -= (curwin->w_skipcol - prev_skipcol) / width2;
        else
-           curwin->w_wrow -= curwin->w_skipcol / width;
+           curwin->w_wrow -= curwin->w_skipcol / width2;
 
        if (curwin->w_wrow >= curwin->w_height)
        {
            // small window, make sure cursor is in it
            extra = curwin->w_wrow - curwin->w_height + 1;
-           curwin->w_skipcol += extra * width;
+           curwin->w_skipcol += extra * width2;
            curwin->w_wrow -= extra;
        }
 
-       extra = ((int)prev_skipcol - (int)curwin->w_skipcol) / width;
+       extra = ((int)prev_skipcol - (int)curwin->w_skipcol) / width2;
        if (extra > 0)
            win_ins_lines(curwin, 0, extra, FALSE, FALSE);
        else if (extra < 0)
index 90fddc3b572eb92bb5edc5664d61e2b67d96503f..dd2788baafc17d53e3bf0a55ccc1cbe637e5ebb6 100644 (file)
@@ -3600,7 +3600,7 @@ struct window_S
                                    // 'wrap' is off
     colnr_T    w_skipcol;          // starting screen column for the first
                                    // line in the window; used when 'wrap' is
-                                   // on
+                                   // on; does not include win_col_off()
 
     int                w_empty_rows;       // number of ~ rows in window
 #ifdef FEAT_DIFF
@@ -4667,8 +4667,8 @@ typedef struct {
                                        // cts_text_props is not used
     textprop_T *cts_text_props;        // text props (allocated)
     char       cts_has_prop_with_text; // TRUE if if a property inserts text
-    int         cts_cur_text_width;     // width of current inserted text
-    int         cts_first_char;                // width text props above the line
+    int                cts_cur_text_width;     // width of current inserted text
+    int                cts_first_char;         // width text props above the line
     int                cts_with_trailing;      // include size of trailing props with
                                        // last character
     int                cts_start_incl;         // prop has true "start_incl" arg
index 8255b851bc24a23faa1570bce38bfef81c7055ad..9719c3d0a2c501588bd8eee47b663927f727527e 100644 (file)
@@ -683,7 +683,7 @@ func Test_breakindent20_cpo_n_nextpage()
   call s:compare_lines(expect, lines)
   " Scroll down one screen line
   setl scrolloff=5
-  norm! 5gj
+  norm! 6gj
   redraw!
   let lines = s:screen_lines(1, 20)
   let expect = [
@@ -691,8 +691,7 @@ func Test_breakindent20_cpo_n_nextpage()
        \ "    mnopqrstabcdefgh",
        \ "    ijklmnopqrstabcd",
        \ ]
-  " FIXME: this currently fails
-  " call s:compare_lines(expect, lines)
+  call s:compare_lines(expect, lines)
 
   setl briopt+=shift:2
   norm! 1gg
@@ -704,15 +703,14 @@ func Test_breakindent20_cpo_n_nextpage()
        \ ]
   call s:compare_lines(expect, lines)
   " Scroll down one screen line
-  norm! 5gj
+  norm! 6gj
   let lines = s:screen_lines(1, 20)
   let expect = [
        \ "<<<   qrstabcdefghij",
        \ "      klmnopqrstabcd",
        \ "      efghijklmnopqr",
        \ ]
-  " FIXME: this currently fails
-  " call s:compare_lines(expect, lines)
+  call s:compare_lines(expect, lines)
 
   call s:close_windows('set breakindent& briopt& cpo& number&')
 endfunc
index 717db79e996e9b9d054e38cbfe50c5e4012fce25..33ae7a66be1033dcd0f91300eeeec5b60eb1dae4 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    746,
 /**/
     745,
 /**/