forked from aniani/vim
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Problem: "[p" in Visual mode puts in wrong line. Solution: Call nv_put() instead of duplicating the functionality. (closes #4408)
This commit is contained in:
70
src/normal.c
70
src/normal.c
@@ -143,6 +143,7 @@ static void nv_at(cmdarg_T *cap);
|
|||||||
static void nv_halfpage(cmdarg_T *cap);
|
static void nv_halfpage(cmdarg_T *cap);
|
||||||
static void nv_join(cmdarg_T *cap);
|
static void nv_join(cmdarg_T *cap);
|
||||||
static void nv_put(cmdarg_T *cap);
|
static void nv_put(cmdarg_T *cap);
|
||||||
|
static void nv_put_opt(cmdarg_T *cap, int fix_indent);
|
||||||
static void nv_open(cmdarg_T *cap);
|
static void nv_open(cmdarg_T *cap);
|
||||||
#ifdef FEAT_NETBEANS_INTG
|
#ifdef FEAT_NETBEANS_INTG
|
||||||
static void nv_nbcmd(cmdarg_T *cap);
|
static void nv_nbcmd(cmdarg_T *cap);
|
||||||
@@ -6583,57 +6584,7 @@ nv_brackets(cmdarg_T *cap)
|
|||||||
*/
|
*/
|
||||||
else if (cap->nchar == 'p' || cap->nchar == 'P')
|
else if (cap->nchar == 'p' || cap->nchar == 'P')
|
||||||
{
|
{
|
||||||
if (!checkclearop(cap->oap))
|
nv_put_opt(cap, TRUE);
|
||||||
{
|
|
||||||
int dir = (cap->cmdchar == ']' && cap->nchar == 'p')
|
|
||||||
? FORWARD : BACKWARD;
|
|
||||||
int regname = cap->oap->regname;
|
|
||||||
int was_visual = VIsual_active;
|
|
||||||
int line_count = curbuf->b_ml.ml_line_count;
|
|
||||||
pos_T start, end;
|
|
||||||
|
|
||||||
if (VIsual_active)
|
|
||||||
{
|
|
||||||
start = LTOREQ_POS(VIsual, curwin->w_cursor)
|
|
||||||
? VIsual : curwin->w_cursor;
|
|
||||||
end = EQUAL_POS(start,VIsual) ? curwin->w_cursor : VIsual;
|
|
||||||
curwin->w_cursor = (dir == BACKWARD ? start : end);
|
|
||||||
}
|
|
||||||
# ifdef FEAT_CLIPBOARD
|
|
||||||
adjust_clip_reg(®name);
|
|
||||||
# endif
|
|
||||||
prep_redo_cmd(cap);
|
|
||||||
|
|
||||||
do_put(regname, dir, cap->count1, PUT_FIXINDENT);
|
|
||||||
if (was_visual)
|
|
||||||
{
|
|
||||||
VIsual = start;
|
|
||||||
curwin->w_cursor = end;
|
|
||||||
if (dir == BACKWARD)
|
|
||||||
{
|
|
||||||
/* adjust lines */
|
|
||||||
VIsual.lnum += curbuf->b_ml.ml_line_count - line_count;
|
|
||||||
curwin->w_cursor.lnum +=
|
|
||||||
curbuf->b_ml.ml_line_count - line_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIsual_active = TRUE;
|
|
||||||
if (VIsual_mode == 'V')
|
|
||||||
{
|
|
||||||
/* delete visually selected lines */
|
|
||||||
cap->cmdchar = 'd';
|
|
||||||
cap->nchar = NUL;
|
|
||||||
cap->oap->regname = regname;
|
|
||||||
nv_operator(cap);
|
|
||||||
do_pending_operator(cap, 0, FALSE);
|
|
||||||
}
|
|
||||||
if (VIsual_active)
|
|
||||||
{
|
|
||||||
end_visual_mode();
|
|
||||||
redraw_later(SOME_VALID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -9289,6 +9240,16 @@ nv_join(cmdarg_T *cap)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
nv_put(cmdarg_T *cap)
|
nv_put(cmdarg_T *cap)
|
||||||
|
{
|
||||||
|
nv_put_opt(cap, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "P", "gP", "p" and "gp" commands.
|
||||||
|
* "fix_indent" is TRUE for "[p", "[P", "]p" and "]P".
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
nv_put_opt(cmdarg_T *cap, int fix_indent)
|
||||||
{
|
{
|
||||||
int regname = 0;
|
int regname = 0;
|
||||||
void *reg1 = NULL, *reg2 = NULL;
|
void *reg1 = NULL, *reg2 = NULL;
|
||||||
@@ -9318,6 +9279,13 @@ nv_put(cmdarg_T *cap)
|
|||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (fix_indent)
|
||||||
|
{
|
||||||
|
dir = (cap->cmdchar == ']' && cap->nchar == 'p')
|
||||||
|
? FORWARD : BACKWARD;
|
||||||
|
flags |= PUT_FIXINDENT;
|
||||||
|
}
|
||||||
|
else
|
||||||
dir = (cap->cmdchar == 'P'
|
dir = (cap->cmdchar == 'P'
|
||||||
|| (cap->cmdchar == 'g' && cap->nchar == 'P'))
|
|| (cap->cmdchar == 'g' && cap->nchar == 'P'))
|
||||||
? BACKWARD : FORWARD;
|
? BACKWARD : FORWARD;
|
||||||
|
@@ -101,3 +101,15 @@ func Test_put_p_errmsg_nodup()
|
|||||||
delfunction Capture_p_error
|
delfunction Capture_p_error
|
||||||
bwipeout!
|
bwipeout!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_put_p_indent_visual()
|
||||||
|
new
|
||||||
|
call setline(1, ['select this text', 'select that text'])
|
||||||
|
" yank "that" from the second line
|
||||||
|
normal 2Gwvey
|
||||||
|
" select "this" in the first line and put
|
||||||
|
normal k0wve[p
|
||||||
|
call assert_equal('select that text', getline(1))
|
||||||
|
call assert_equal('select that text', getline(2))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1373,
|
||||||
/**/
|
/**/
|
||||||
1372,
|
1372,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user