Skip to content

Commit 293902f

Browse files
committed
updated for version 7.3.627
Problem: When using the "n" flag with the ":s" command a \= substitution will not be evaluated. Solution: Do perform the evaluation, so that a function can be invoked at every matching position without changing the text. (Christian Brabandt)
1 parent 9b371f1 commit 293902f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/ex_cmds.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4264,6 +4264,9 @@ do_sub(eap)
42644264
int endcolumn = FALSE; /* cursor in last column when done */
42654265
pos_T old_cursor = curwin->w_cursor;
42664266
int start_nsubs;
4267+
#ifdef FEAT_EVAL
4268+
int save_ma = 0;
4269+
#endif
42674270

42684271
cmd = eap->arg;
42694272
if (!global_busy)
@@ -4668,7 +4671,12 @@ do_sub(eap)
46684671
}
46694672
sub_nsubs++;
46704673
did_sub = TRUE;
4671-
goto skip;
4674+
#ifdef FEAT_EVAL
4675+
/* Skip the substitution, unless an expression is used,
4676+
* then it is evaluated in the sandbox. */
4677+
if (!(sub[0] == '\\' && sub[1] == '='))
4678+
#endif
4679+
goto skip;
46724680
}
46734681

46744682
if (do_ask)
@@ -4840,10 +4848,27 @@ do_sub(eap)
48404848
/*
48414849
* 3. substitute the string.
48424850
*/
4851+
#ifdef FEAT_EVAL
4852+
if (do_count)
4853+
{
4854+
/* prevent accidently changing the buffer by a function */
4855+
save_ma = curbuf->b_p_ma;
4856+
curbuf->b_p_ma = FALSE;
4857+
sandbox++;
4858+
}
4859+
#endif
48434860
/* get length of substitution part */
48444861
sublen = vim_regsub_multi(&regmatch,
48454862
sub_firstlnum - regmatch.startpos[0].lnum,
48464863
sub, sub_firstline, FALSE, p_magic, TRUE);
4864+
#ifdef FEAT_EVAL
4865+
if (do_count)
4866+
{
4867+
curbuf->b_p_ma = save_ma;
4868+
sandbox--;
4869+
goto skip;
4870+
}
4871+
#endif
48474872

48484873
/* When the match included the "$" of the last line it may
48494874
* go beyond the last line of the buffer. */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
627,
717719
/**/
718720
626,
719721
/**/

0 commit comments

Comments
 (0)