aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2022-01-21 09:36:26 +0900
committerShougo Matsushita <Shougo.Matsu@gmail.com>2022-01-22 11:57:06 +0900
commitd7ab4e819a89c12b74772217e725c640858a18c6 (patch)
treefbbc990be752cee4b482c31057dc29897812a9b3 /src/nvim/normal.c
parent431915fe6af4e176a84a60c95ad7aa9d36b71e50 (diff)
downloadrneovim-d7ab4e819a89c12b74772217e725c640858a18c6.tar.gz
rneovim-d7ab4e819a89c12b74772217e725c640858a18c6.tar.bz2
rneovim-d7ab4e819a89c12b74772217e725c640858a18c6.zip
vim-patch:8.2.4160: cannot change the register used for Select mode delete
Problem: Cannot change the register used for Select mode delete. Solution: Make CTRL-R set the register to be used when deleting text for Select mode. (Shougo Matsushita, closes vim/vim#9531) https://github.com/vim/vim/commit/4ede01f18884961f2e008880b4964e5d61ea5c36
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 2b5b47c0b3..2fce3e10b8 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -164,7 +164,7 @@ static const struct nv_cmd {
{ Ctrl_O, nv_ctrlo, 0, 0 },
{ Ctrl_P, nv_up, NV_STS, false },
{ Ctrl_Q, nv_visual, 0, false },
- { Ctrl_R, nv_redo, 0, 0 },
+ { Ctrl_R, nv_redo_or_register, 0, 0 },
{ Ctrl_S, nv_ignore, 0, 0 },
{ Ctrl_T, nv_tagpop, NV_NCW, 0 },
{ Ctrl_U, nv_halfpage, 0, 0 },
@@ -961,6 +961,7 @@ normal_end:
&& s->oa.regname == 0) {
if (restart_VIsual_select == 1) {
VIsual_select = true;
+ VIsual_select_reg = 0;
trigger_modechanged();
showmode();
restart_VIsual_select = 0;
@@ -6186,6 +6187,7 @@ static void nv_g_cmd(cmdarg_T *cap)
// start Select mode.
if (cap->arg) {
VIsual_select = true;
+ VIsual_select_reg = 0;
} else {
may_start_select('c');
}
@@ -6698,11 +6700,26 @@ static void nv_dot(cmdarg_T *cap)
}
}
-/*
- * CTRL-R: undo undo
- */
-static void nv_redo(cmdarg_T *cap)
+// CTRL-R: undo undo or specify register in select mode
+static void nv_redo_or_register(cmdarg_T *cap)
{
+ if (VIsual_select && VIsual_active) {
+ int reg;
+ // Get register name
+ no_mapping++;
+ reg = plain_vgetc();
+ LANGMAP_ADJUST(reg, true);
+ no_mapping--;
+
+ if (reg == '"') {
+ // the unnamed register is 0
+ reg = 0;
+ }
+
+ VIsual_select_reg = valid_yank_reg(reg, true) ? reg : 0;
+ return;
+ }
+
if (!checkclearopq(cap->oap)) {
u_redo((int)cap->count1);
curwin->w_set_curswant = true;
@@ -7023,6 +7040,7 @@ static void nv_select(cmdarg_T *cap)
{
if (VIsual_active) {
VIsual_select = true;
+ VIsual_select_reg = 0;
} else if (VIsual_reselect) {
cap->nchar = 'v'; // fake "gv" command
cap->arg = true;