diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-01-14 19:35:14 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-01-14 19:35:14 +0100 |
commit | d574ea2f80b271aff4bac7dc7fa83b292f0ac486 (patch) | |
tree | c7753824b197d5bb0c9193fcea12eb0a4ce730dc /src/charset.c | |
parent | 084abaec061f830e2d389c416499d013e47fb0db (diff) | |
download | vim-git-d574ea2f80b271aff4bac7dc7fa83b292f0ac486.tar.gz |
updated for version 7.4.579v7.4.579
Problem: Wrong cursor positioning when 'linebreak' is set and lines wrap.
Solution: (Christian Brabandt)
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/charset.c b/src/charset.c index e9745c09a..53d2a60a4 100644 --- a/src/charset.c +++ b/src/charset.c @@ -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); |