aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorPedro L. Ramos <pedro.2.ramos@nokia.com>2019-01-07 15:48:44 +0000
committerJustin M. Keyes <justinkz@gmail.com>2019-01-10 08:50:07 +0100
commit57c7e1d4a0d7285d9de5b9035e91f546654268da (patch)
tree78b6da87e2f0aecb4ac85b0c0d0921b8f7995639 /src/nvim/normal.c
parent1ca2c8950fe33654f046183516a123fe0606b4e8 (diff)
downloadrneovim-57c7e1d4a0d7285d9de5b9035e91f546654268da.tar.gz
rneovim-57c7e1d4a0d7285d9de5b9035e91f546654268da.tar.bz2
rneovim-57c7e1d4a0d7285d9de5b9035e91f546654268da.zip
vim-patch:8.1.0648: custom operators can't act upon forced motion
Problem: Custom operators can't act upon a forced motion. (Christian Wellenbrock) Solution: Add the forced motion to the mode() result. (Christian Brabandt, closes vim/vim#3490) https://github.com/vim/vim/commit/5976f8ff00efcb3e155a89346e44f2ad43d2405a closes #8667 closes #9476 Christian Wellenbrock: > For (most) built in text objects it's possible to force operation on > them to be linewise, for example by using `dVab` (`:h o_V`, > `motion_force`). When using custom text objects (defined as mappings > by plugins for example), this doesn't currently work. > > Example: > > onoremap x viw > > Open a file with a few lines each containing some words. With the > cursor on any word, try: > > 1. `dw` (builtin) deletes some characters > 2. `dVw` (builtin) deletes linewise > 3. `dx` (from mapping) deletes some characters > 4. `dVx` (from mapping) deletes some characters, but should delete > linewise ref: https://github.com/wellle/targets.vim/issues/214 ref: https://gitter.im/neovim/neovim?at=5b379ff7f1664406610e7483
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 705dea4e88..29c5d27258 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1445,8 +1445,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
oap->motion_type = kMTCharWise;
} else if (oap->motion_force == Ctrl_V) {
// Change line- or characterwise motion into Visual block mode.
- VIsual_active = true;
- VIsual = oap->start;
+ if (!VIsual_active) {
+ VIsual_active = true;
+ VIsual = oap->start;
+ }
VIsual_mode = Ctrl_V;
VIsual_select = false;
VIsual_reselect = false;
@@ -2039,6 +2041,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
curwin->w_cursor = old_cursor;
}
clearop(oap);
+ motion_force = NUL;
}
curwin->w_p_lbr = lbr_saved;
}
@@ -6389,8 +6392,8 @@ static void nv_visual(cmdarg_T *cap)
/* 'v', 'V' and CTRL-V can be used while an operator is pending to make it
* characterwise, linewise, or blockwise. */
if (cap->oap->op_type != OP_NOP) {
- cap->oap->motion_force = cap->cmdchar;
- finish_op = false; /* operator doesn't finish now but later */
+ motion_force = cap->oap->motion_force = cap->cmdchar;
+ finish_op = false; // operator doesn't finish now but later
return;
}