diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-06-12 07:48:28 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-06-12 20:42:30 +0800 |
commit | 41bb81a2dfe3c173a5d8f9d7c200475028221cf3 (patch) | |
tree | 238df43e486cbd67be253cbfcc1ef24f544553b4 /src/nvim | |
parent | 502f03fc064d1eb427d214521d5cb9f5425a15b4 (diff) | |
download | rneovim-41bb81a2dfe3c173a5d8f9d7c200475028221cf3.tar.gz rneovim-41bb81a2dfe3c173a5d8f9d7c200475028221cf3.tar.bz2 rneovim-41bb81a2dfe3c173a5d8f9d7c200475028221cf3.zip |
fix(substitute): subtract number of backslashes later
Diffstat (limited to 'src/nvim')
-rw-r--r-- | src/nvim/ex_cmds.c | 1 | ||||
-rw-r--r-- | src/nvim/regexp.c | 7 |
2 files changed, 2 insertions, 6 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 6fa3f1b427..9bb77ce928 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4142,6 +4142,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T // That is Vi compatible. for (p1 = new_end; *p1; p1++) { if (p1[0] == '\\' && p1[1] != NUL) { // remove backslash + sublen--; // correct the byte counts for extmark_splice() STRMOVE(p1, p1 + 1); } else if (*p1 == CAR) { if (u_inssub(lnum) == OK) { // prepare for undo diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 44c9928f7b..352f4dfe39 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1737,10 +1737,6 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des static char_u *eval_result = NULL; bool copy = flags & REGSUB_COPY; - // We need to keep track of how many backslashes we escape, so that the byte - // counts for `extmark_splice` are correct. - int num_escaped = 0; - // Be paranoid... if ((source == NULL && expr == NULL) || dest == NULL) { emsg(_(e_null)); @@ -1928,7 +1924,6 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des // later. Used to insert a literal CR. default: if (flags & REGSUB_BACKSLASH) { - num_escaped += 1; if (copy) { if (dst + 1 > dest + destlen) { iemsg("vim_regsub_both(): not enough space"); @@ -2096,7 +2091,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des } exit: - return (int)((dst - dest) + 1 - num_escaped); + return (int)((dst - dest) + 1); } /* |