]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.4.579 v7.4.579
authorBram Moolenaar <Bram@vim.org>
Wed, 14 Jan 2015 18:35:14 +0000 (19:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 14 Jan 2015 18:35:14 +0000 (19:35 +0100)
Problem:    Wrong cursor positioning when 'linebreak' is set and lines wrap.
Solution:   (Christian Brabandt)

src/charset.c
src/screen.c
src/version.c

index e9745c09a243497823cb18fa6ea9b03a8aad5173..53d2a60a40696f83601726d93130567eac32ad2b 100644 (file)
@@ -1178,28 +1178,50 @@ win_lbr_chartabsize(wp, line, s, col, headp)
     added = 0;
     if ((*p_sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && col != 0)
     {
-       numberextra = win_col_off(wp);
+       colnr_T sbrlen = 0;
+       int     numberwidth = win_col_off(wp);
+
+       numberextra = numberwidth;
        col += numberextra + mb_added;
        if (col >= (colnr_T)W_WIDTH(wp))
        {
            col -= W_WIDTH(wp);
            numberextra = W_WIDTH(wp) - (numberextra - win_col_off2(wp));
-           if (numberextra > 0)
+           if (col >= numberextra && numberextra > 0)
                col %= numberextra;
            if (*p_sbr != NUL)
            {
-               colnr_T sbrlen = (colnr_T)MB_CHARLEN(p_sbr);
+               sbrlen = (colnr_T)MB_CHARLEN(p_sbr);
                if (col >= sbrlen)
                    col -= sbrlen;
            }
-           if (numberextra > 0)
+           if (col >= numberextra && numberextra > 0)
                col = col % numberextra;
+           else if (col > 0 && numberextra > 0)
+               col += numberwidth - win_col_off2(wp);
+
+           numberwidth -= win_col_off2(wp);
        }
-       if (col == 0 || col + size > (colnr_T)W_WIDTH(wp))
+       if (col == 0 || col + size + sbrlen > (colnr_T)W_WIDTH(wp))
        {
            added = 0;
            if (*p_sbr != NUL)
-               added += vim_strsize(p_sbr);
+           {
+               if (size + sbrlen + numberwidth > (colnr_T)W_WIDTH(wp))
+               {
+                   /* calculate effective window width */
+                   int width = (colnr_T)W_WIDTH(wp) - sbrlen - numberwidth;
+                   int prev_width = col ? ((colnr_T)W_WIDTH(wp) - (sbrlen + col)) : 0;
+                   if (width == 0)
+                       width = (colnr_T)W_WIDTH(wp);
+                   added += ((size - prev_width) / width) * vim_strsize(p_sbr);
+                   if ((size - prev_width) % width)
+                       /* wrapped, add another length of 'sbr' */
+                       added += vim_strsize(p_sbr);
+               }
+               else
+                   added += vim_strsize(p_sbr);
+           }
            if (wp->w_p_bri)
                added += get_breakindent_win(wp, line);
 
index bbf57b1121f5c7bc8ec8e60db6fa4e9c76ffcdd8..b767ec3c15ab029d3ec210639114eabfe6703e97 100644 (file)
@@ -2842,6 +2842,9 @@ win_line(wp, lnum, startrow, endrow, nochange)
     unsigned   off;                    /* offset in ScreenLines/ScreenAttrs */
     int                c = 0;                  /* init for GCC */
     long       vcol = 0;               /* virtual column (for tabs) */
+#ifdef FEAT_LINEBREAK
+    long       vcol_sbr = -1;          /* virtual column after showbreak */
+#endif
     long       vcol_prev = -1;         /* "vcol" of previous character */
     char_u     *line;                  /* current line */
     char_u     *ptr;                   /* current position in "line" */
@@ -3759,6 +3762,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
                    n_extra = (int)STRLEN(p_sbr);
                    char_attr = hl_attr(HLF_AT);
                    need_showbreak = FALSE;
+                   vcol_sbr = vcol + MB_CHARLEN(p_sbr);
                    /* Correct end of highlighted area for 'showbreak',
                     * required when 'linebreak' is also set. */
                    if (tocol == vcol)
@@ -4516,9 +4520,17 @@ win_line(wp, lnum, startrow, endrow, nochange)
                if (c == TAB && (!wp->w_p_list || lcs_tab1))
                {
                    int tab_len = 0;
+                   long vcol_adjusted = vcol; /* removed showbreak length */
+#ifdef FEAT_LINEBREAK
+                   /* only adjust the tab_len, when at the first column
+                    * after the showbreak value was drawn */
+                   if (*p_sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap)
+                       vcol_adjusted = vcol - MB_CHARLEN(p_sbr);
+#endif
                    /* tab amount depends on current column */
                    tab_len = (int)wp->w_buffer->b_p_ts
-                                       - vcol % (int)wp->w_buffer->b_p_ts - 1;
+                                       - vcol_adjusted % (int)wp->w_buffer->b_p_ts - 1;
+
 #ifdef FEAT_LINEBREAK
                    if (!wp->w_p_lbr || !wp->w_p_list)
 #endif
index 7a54fc28518d39a830173fd13ca1f74809de6294..e6ab37e5a1dea3d8d02fe17a9c05df34d59faed2 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    579,
 /**/
     578,
 /**/