mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
updated for version 7.4.064
Problem: When replacing a character in Visual block mode, entering a CR does not cause a repeated line break. Solution: Recognize the situation and repeat the line break. (Christian Brabandt)
This commit is contained in:
parent
ba2d7ffc4b
commit
d9820538bd
@ -7036,6 +7036,13 @@ nv_replace(cap)
|
|||||||
{
|
{
|
||||||
if (got_int)
|
if (got_int)
|
||||||
reset_VIsual();
|
reset_VIsual();
|
||||||
|
if (had_ctrl_v)
|
||||||
|
{
|
||||||
|
if (cap->nchar == '\r')
|
||||||
|
cap->nchar = -1;
|
||||||
|
else if (cap->nchar == '\n')
|
||||||
|
cap->nchar = -2;
|
||||||
|
}
|
||||||
nv_operator(cap);
|
nv_operator(cap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
23
src/ops.c
23
src/ops.c
@ -2074,10 +2074,15 @@ op_replace(oap, c)
|
|||||||
char_u *newp, *oldp;
|
char_u *newp, *oldp;
|
||||||
size_t oldlen;
|
size_t oldlen;
|
||||||
struct block_def bd;
|
struct block_def bd;
|
||||||
|
char_u *after_p = NULL;
|
||||||
|
int had_ctrl_v_cr = (c == -1 || c == -2);
|
||||||
|
|
||||||
if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
|
if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
|
||||||
return OK; /* nothing to do */
|
return OK; /* nothing to do */
|
||||||
|
|
||||||
|
if (had_ctrl_v_cr)
|
||||||
|
c = (c == -1 ? '\r' : '\n');
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
mb_adjust_opend(oap);
|
mb_adjust_opend(oap);
|
||||||
@ -2164,6 +2169,9 @@ op_replace(oap, c)
|
|||||||
/* insert pre-spaces */
|
/* insert pre-spaces */
|
||||||
copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
|
copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
|
||||||
/* insert replacement chars CHECK FOR ALLOCATED SPACE */
|
/* insert replacement chars CHECK FOR ALLOCATED SPACE */
|
||||||
|
/* -1/-2 is used for entering CR literally. */
|
||||||
|
if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
|
||||||
|
{
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
@ -2181,8 +2189,23 @@ op_replace(oap, c)
|
|||||||
/* copy the part after the changed part */
|
/* copy the part after the changed part */
|
||||||
STRMOVE(newp + STRLEN(newp), oldp);
|
STRMOVE(newp + STRLEN(newp), oldp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Replacing with \r or \n means splitting the line. */
|
||||||
|
after_p = alloc_check((unsigned)oldlen + 1 + n - STRLEN(newp));
|
||||||
|
if (after_p != NULL)
|
||||||
|
STRMOVE(after_p, oldp);
|
||||||
|
}
|
||||||
/* replace the line */
|
/* replace the line */
|
||||||
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
|
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
|
||||||
|
if (after_p != NULL)
|
||||||
|
{
|
||||||
|
ml_append(curwin->w_cursor.lnum++, after_p, 0, FALSE);
|
||||||
|
appended_lines_mark(curwin->w_cursor.lnum, 1L);
|
||||||
|
oap->end.lnum++;
|
||||||
|
vim_free(after_p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -32,6 +32,10 @@ Oblah di
|
|||||||
doh dutVkUj
|
doh dutVkUj
|
||||||
:" Uppercase part of two lines
|
:" Uppercase part of two lines
|
||||||
ddppi333k0i222fyllvjfuUk
|
ddppi333k0i222fyllvjfuUk
|
||||||
|
:" visual replace using Enter or NL
|
||||||
|
G3o1234567892k05l2jr
G3o987652k02l2jr
|
||||||
|
G3o1234567892k05l2jr
|
||||||
|
G3o987652k02l2jr
|
||||||
:/^the/,$w >> test.out
|
:/^the/,$w >> test.out
|
||||||
:qa!
|
:qa!
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
Binary file not shown.
@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
64,
|
||||||
/**/
|
/**/
|
||||||
63,
|
63,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user