diff options
Diffstat (limited to 'src/nvim/change.c')
-rw-r--r-- | src/nvim/change.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index b8bc08b747..71614363d2 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -362,8 +362,7 @@ void changed_bytes(linenr_T lnum, colnr_T col) /// insert/delete bytes at column /// /// Like changed_bytes() but also adjust extmark for "new" bytes. -/// When "new" is negative text was deleted. -static void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new) +void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new) { if (curbuf_splice_pending == 0) { extmark_splice_cols(curbuf, (int)lnum-1, col, old, new, kExtmarkUndo); @@ -1677,9 +1676,16 @@ int open_line( truncate_spaces(saved_line); } ml_replace(curwin->w_cursor.lnum, saved_line, false); - extmark_splice_cols( - curbuf, (int)curwin->w_cursor.lnum, - 0, curwin->w_cursor.col, (int)STRLEN(saved_line), kExtmarkUndo); + + int new_len = (int)STRLEN(saved_line); + + // TODO(vigoux): maybe there is issues there with expandtabs ? + if (new_len < curwin->w_cursor.col) { + extmark_splice_cols( + curbuf, (int)curwin->w_cursor.lnum, + new_len, curwin->w_cursor.col - new_len, 0, kExtmarkUndo); + } + saved_line = NULL; if (did_append) { changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col, |