diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-09-18 08:44:32 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-09-18 17:54:49 +0200 |
commit | 179f0bca1890637f47e76c8acfd33040a6b7d515 (patch) | |
tree | 551c89be8be222f827a2bdc1e481c48b10710593 /src | |
parent | 6dc815530b7b127c5b5e0912783c3f2118cb184f (diff) | |
download | rneovim-179f0bca1890637f47e76c8acfd33040a6b7d515.tar.gz rneovim-179f0bca1890637f47e76c8acfd33040a6b7d515.tar.bz2 rneovim-179f0bca1890637f47e76c8acfd33040a6b7d515.zip |
buf_updates: fix wrong updates on linewise change
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ops.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1f55d2c315..92d026465f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1544,15 +1544,19 @@ int op_delete(oparg_T *oap) oap->line_count = 0; // no lines deleted } else if (oap->motion_type == kMTLineWise) { if (oap->op_type == OP_CHANGE) { - /* Delete the lines except the first one. Temporarily move the - * cursor to the next line. Save the current line number, if the - * last line is deleted it may be changed. - */ + // Delete the lines except the first one. Temporarily move the + // cursor to the next line. Save the current line number, if the + // last line is deleted it may be changed. + if (oap->line_count > 1) { lnum = curwin->w_cursor.lnum; ++curwin->w_cursor.lnum; del_lines(oap->line_count - 1, TRUE); curwin->w_cursor.lnum = lnum; + + extmark_adjust(curbuf, curwin->w_cursor.lnum, + curwin->w_cursor.lnum + oap->line_count - 1, + MAXLNUM, 0, kExtmarkUndo); } if (u_save_cursor() == FAIL) return FAIL; @@ -1561,9 +1565,16 @@ int op_delete(oparg_T *oap) did_ai = true; // delete the indent when ESC hit ai_col = curwin->w_cursor.col; } else - beginline(0); /* cursor in column 0 */ - truncate_line(FALSE); /* delete the rest of the line */ - /* leave cursor past last char in line */ + beginline(0); // cursor in column 0 + + int old_len = (int)STRLEN(ml_get(curwin->w_cursor.lnum)); + truncate_line(FALSE); // delete the rest of the line + + extmark_splice_cols(curbuf, + (int)curwin->w_cursor.lnum, curwin->w_cursor.col, + old_len - curwin->w_cursor.col, 0, kExtmarkUndo); + + // leave cursor past last char in line if (oap->line_count > 1) u_clearline(); /* "U" command not possible after "2cc" */ } else { |