aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-22 11:10:24 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-01-22 11:10:24 +0100
commit043d8ba422b4f35d82e8acef8438248de94ab167 (patch)
treef87277f9d764b19fdcd529db24d4f0854b8ed81c /src/nvim/normal.c
parentc86caf7e41c77f85861fc92e1ef1462508d74b24 (diff)
parentb7ee8fbc814c94ce6667a4d7701e53d7724ee260 (diff)
downloadrneovim-043d8ba422b4f35d82e8acef8438248de94ab167.tar.gz
rneovim-043d8ba422b4f35d82e8acef8438248de94ab167.tar.bz2
rneovim-043d8ba422b4f35d82e8acef8438248de94ab167.zip
Merge #5782 'Visual-mode put from @. register'
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 227bfbe779..9db02de2a6 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1517,10 +1517,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
coladvance(curwin->w_curswant);
}
cap->count0 = redo_VIsual_count;
- if (redo_VIsual_count != 0)
- cap->count1 = redo_VIsual_count;
- else
- cap->count1 = 1;
+ cap->count1 = (cap->count0 == 0 ? 1 : cap->count0);
} else if (VIsual_active) {
if (!gui_yank) {
/* Save the current VIsual area for '< and '> marks, and "gv" */
@@ -7727,16 +7724,22 @@ static void nv_put(cmdarg_T *cap)
savereg = copy_register(regname);
}
- /* Now delete the selected text. */
- cap->cmdchar = 'd';
- cap->nchar = NUL;
- cap->oap->regname = NUL;
- nv_operator(cap);
- do_pending_operator(cap, 0, false);
- empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
+ // To place the cursor correctly after a blockwise put, and to leave the
+ // text in the correct position when putting over a selection with
+ // 'virtualedit' and past the end of the line, we use the 'c' operator in
+ // do_put(), which requires the visual selection to still be active.
+ if (!VIsual_active || VIsual_mode == 'V' || regname != '.') {
+ // Now delete the selected text.
+ cap->cmdchar = 'd';
+ cap->nchar = NUL;
+ cap->oap->regname = NUL;
+ nv_operator(cap);
+ do_pending_operator(cap, 0, false);
+ empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
- /* delete PUT_LINE_BACKWARD; */
- cap->oap->regname = regname;
+ // delete PUT_LINE_BACKWARD;
+ cap->oap->regname = regname;
+ }
/* When deleted a linewise Visual area, put the register as
* lines to avoid it joined with the next line. When deletion was