diff options
author | Felipe Morales <hel.sheep@gmail.com> | 2014-06-26 00:21:57 -0400 |
---|---|---|
committer | Felipe Morales <hel.sheep@gmail.com> | 2014-08-20 05:19:49 -0400 |
commit | 47391b18e2084f2747b10aa6158bc40e03f01528 (patch) | |
tree | c4964c57901313d4067f80325d320cc94a579b49 /src/nvim/edit.c | |
parent | bbefc73c553d681f78f40df9d97ec89ae9b06520 (diff) | |
download | rneovim-47391b18e2084f2747b10aa6158bc40e03f01528.tar.gz rneovim-47391b18e2084f2747b10aa6158bc40e03f01528.tar.bz2 rneovim-47391b18e2084f2747b10aa6158bc40e03f01528.zip |
Port vim's patch 7.4.338 ('breakindent')
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r-- | src/nvim/edit.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 93e127394b..6158176e56 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -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; |