aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-08-20 12:24:34 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-08-20 12:24:34 -0400
commit118a31c24c7ce76da909026cd10a94feb88803bc (patch)
tree8bbd708d924ef68017949e4bf9b773d5d833b82d /src/nvim/edit.c
parentbbefc73c553d681f78f40df9d97ec89ae9b06520 (diff)
parent3b0f7fe59392138c886063b09e3cf41b25d53056 (diff)
downloadrneovim-118a31c24c7ce76da909026cd10a94feb88803bc.tar.gz
rneovim-118a31c24c7ce76da909026cd10a94feb88803bc.tar.bz2
rneovim-118a31c24c7ce76da909026cd10a94feb88803bc.zip
Merge pull request #691 from fmoralesc/master
Port vim's breakindent patch to neovim's codebase. (vim patches 7.4.338, 7.4.346, 7.4.352, 7.4.353, 7.4.370, 7.4.371, 7.4.388)
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c22
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;