Skip to content

Commit 69860fe

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 07dd3d0 + f12519d commit 69860fe

6 files changed

Lines changed: 47 additions & 12 deletions

File tree

src/Make_mvc.mak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ MSVC_MAJOR = ($(MSVCVER) / 100 - 6)
289289
MSVCRT_VER = ($(MSVCVER) / 10 - 60)
290290
# Visual C++ 2017 needs special handling
291291
# it has an _MSC_VER of 1910->14.1, but is actually v15 with runtime v140
292-
!elseif $(MSVCVER) == 1910
292+
# TODO: what's the maximum value?
293+
!elseif $(MSVCVER) >= 1910
293294
MSVC_MAJOR = 15
294295
MSVCRT_VER = 140
295296
!else

src/normal.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,11 +1685,19 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
16851685
get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
16861686
oap->motion_force, cap->cmdchar, cap->nchar);
16871687
else if (cap->cmdchar != ':')
1688+
{
1689+
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
1690+
1691+
/* reverse what nv_replace() did */
1692+
if (nchar == REPLACE_CR_NCHAR)
1693+
nchar = CAR;
1694+
else if (nchar == REPLACE_NL_NCHAR)
1695+
nchar = NL;
16881696
prep_redo(oap->regname, 0L, NUL, 'v',
16891697
get_op_char(oap->op_type),
16901698
get_extra_op_char(oap->op_type),
1691-
oap->op_type == OP_REPLACE
1692-
? cap->nchar : NUL);
1699+
nchar);
1700+
}
16931701
if (!redo_VIsual_busy)
16941702
{
16951703
redo_VIsual_mode = resel_VIsual_mode;
@@ -7057,10 +7065,12 @@ nv_replace(cmdarg_T *cap)
70577065
reset_VIsual();
70587066
if (had_ctrl_v)
70597067
{
7060-
if (cap->nchar == '\r')
7061-
cap->nchar = -1;
7062-
else if (cap->nchar == '\n')
7063-
cap->nchar = -2;
7068+
/* Use a special (negative) number to make a difference between a
7069+
* literal CR or NL and a line break. */
7070+
if (cap->nchar == CAR)
7071+
cap->nchar = REPLACE_CR_NCHAR;
7072+
else if (cap->nchar == NL)
7073+
cap->nchar = REPLACE_NL_NCHAR;
70647074
}
70657075
nv_operator(cap);
70667076
return;

src/ops.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,13 +2113,21 @@ op_replace(oparg_T *oap, int c)
21132113
size_t oldlen;
21142114
struct block_def bd;
21152115
char_u *after_p = NULL;
2116-
int had_ctrl_v_cr = (c == -1 || c == -2);
2116+
int had_ctrl_v_cr = FALSE;
21172117

21182118
if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty)
21192119
return OK; /* nothing to do */
21202120

2121-
if (had_ctrl_v_cr)
2122-
c = (c == -1 ? '\r' : '\n');
2121+
if (c == REPLACE_CR_NCHAR)
2122+
{
2123+
had_ctrl_v_cr = TRUE;
2124+
c = CAR;
2125+
}
2126+
else if (c == REPLACE_NL_NCHAR)
2127+
{
2128+
had_ctrl_v_cr = TRUE;
2129+
c = NL;
2130+
}
21232131

21242132
#ifdef FEAT_MBYTE
21252133
if (has_mbyte)
@@ -2207,7 +2215,8 @@ op_replace(oparg_T *oap, int c)
22072215
/* insert pre-spaces */
22082216
vim_memset(newp + bd.textcol, ' ', (size_t)bd.startspaces);
22092217
/* insert replacement chars CHECK FOR ALLOCATED SPACE */
2210-
/* -1/-2 is used for entering CR literally. */
2218+
/* REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR
2219+
* literally. */
22112220
if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
22122221
{
22132222
#ifdef FEAT_MBYTE
@@ -6370,7 +6379,7 @@ write_viminfo_registers(FILE *fp)
63706379
* |{bartype},{flags},{name},{type},
63716380
* {linecount},{width},{timestamp},"line1","line2"
63726381
* flags: REG_PREVIOUS - register is y_previous
6373-
* REG_EXEC - used for @@
6382+
* REG_EXEC - used for @@
63746383
*/
63756384
if (y_previous == &y_regs[i])
63766385
flags |= REG_PREVIOUS;

src/testdir/test_undo.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,10 @@ func Test_undo_0()
403403

404404
bwipe!
405405
endfunc
406+
407+
func Test_redo_empty_line()
408+
new
409+
exe "norm\x16r\x160"
410+
exe "norm."
411+
bwipe!
412+
endfunc

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ static char *(features[]) =
786786

787787
static int included_patches[] =
788788
{ /* Add new patch number below this line */
789+
/**/
790+
1475,
791+
/**/
792+
1474,
789793
/**/
790794
1473,
791795
/**/

src/vim.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,4 +2517,8 @@ typedef enum {
25172517
# endif
25182518
#endif
25192519

2520+
/* Replacement for nchar used by nv_replace(). */
2521+
#define REPLACE_CR_NCHAR -1
2522+
#define REPLACE_NL_NCHAR -2
2523+
25202524
#endif /* VIM__H */

0 commit comments

Comments
 (0)