Port vim's patch 7.4.338 ('breakindent')

This commit is contained in:
Felipe Morales
2014-06-26 00:21:57 -04:00
parent bbefc73c55
commit 47391b18e2
14 changed files with 381 additions and 63 deletions

View File

@@ -1551,7 +1551,7 @@ change_indent (
new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);
else
++new_cursor_col;
vcol += lbr_chartabsize(ptr + new_cursor_col, (colnr_T)vcol);
vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
}
vcol = last_vcol;
@@ -5898,9 +5898,11 @@ int oneleft(void)
width = 1;
for (;; ) {
coladvance(v - width);
/* getviscol() is slow, skip it when 'showbreak' is empty and
* there are no multi-byte characters */
/* getviscol() is slow, skip it when 'showbreak' is empty,
'breakindent' is not set and there are no multi-byte
characters */
if ((*p_sbr == NUL
&& !curwin->w_p_bri
&& !has_mbyte
) || getviscol() < v)
break;
@@ -7914,10 +7916,10 @@ static int ins_tab(void)
getvcol(curwin, &fpos, &vcol, NULL, NULL);
getvcol(curwin, cursor, &want_vcol, NULL, NULL);
/* Use as many TABs as possible. Beware of 'showbreak' and
* 'linebreak' adding extra virtual columns. */
/* Use as many TABs as possible. Beware of 'breakindent', 'showbreak'
and 'linebreak' adding extra virtual columns. */
while (vim_iswhite(*ptr)) {
i = lbr_chartabsize((char_u *)"\t", vcol);
i = lbr_chartabsize(NULL, (char_u *)"\t", vcol);
if (vcol + i > want_vcol)
break;
if (*ptr != TAB) {
@@ -7936,10 +7938,11 @@ static int ins_tab(void)
if (change_col >= 0) {
int repl_off = 0;
char_u *line = ptr;
/* Skip over the spaces we need. */
while (vcol < want_vcol && *ptr == ' ') {
vcol += lbr_chartabsize(ptr, vcol);
vcol += lbr_chartabsize(line, ptr, vcol);
++ptr;
++repl_off;
}
@@ -8126,6 +8129,7 @@ int ins_copychar(linenr_T lnum)
int c;
int temp;
char_u *ptr, *prev_ptr;
char_u *line;
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) {
vim_beep();
@@ -8134,12 +8138,12 @@ int ins_copychar(linenr_T lnum)
/* try to advance to the cursor column */
temp = 0;
ptr = ml_get(lnum);
line = ptr = ml_get(lnum);
prev_ptr = ptr;
validate_virtcol();
while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL) {
prev_ptr = ptr;
temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp);
temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp);
}
if ((colnr_T)temp > curwin->w_virtcol)
ptr = prev_ptr;