diff options
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 645dcc0865..9a01891483 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2643,8 +2643,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) char command_start_char = non_linewise_vis ? 'c' : (flags & PUT_LINE ? 'i' : (dir == FORWARD ? 'a' : 'i')); - // To avoid being the affect of 'autoindent' on linewise puts, we create a - // new line with `:put _`. + // To avoid 'autoindent' on linewise puts, create a new line with `:put _`. if (flags & PUT_LINE) { do_put('_', NULL, dir, 1, PUT_LINE); } @@ -2668,6 +2667,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } else { (void)stuff_inserted(command_start_char, count, false); } + // Putting the text is done later, so can't move the cursor to the next // character. Simulate it with motion commands after the insert. if (flags & PUT_CURSEND) { @@ -2689,17 +2689,15 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) // incremented instead of curwin->w_cursor.col. char_u *cursor_pos = get_cursor_pos_ptr(); bool one_past_line = (*cursor_pos == NUL); - bool end_of_line = false; + bool eol = false; if (!one_past_line) { - end_of_line = (*(cursor_pos + mb_ptr2len(cursor_pos)) == NUL); + eol = (*(cursor_pos + mb_ptr2len(cursor_pos)) == NUL); } - bool virtualedit_allows = (ve_flags == VE_ALL - || ve_flags == VE_ONEMORE); - bool end_of_file = ( - (curbuf->b_ml.ml_line_count == curwin->w_cursor.lnum) - && one_past_line); - if (virtualedit_allows || !(end_of_line || end_of_file)) { + bool ve_allows = (ve_flags == VE_ALL || ve_flags == VE_ONEMORE); + bool eof = curbuf->b_ml.ml_line_count == curwin->w_cursor.lnum + && one_past_line; + if (ve_allows || !(eol || eof)) { stuffcharReadbuff('l'); } } |