diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-02-06 10:18:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 10:18:59 +0800 |
commit | 8215c05945054755b2c3cadae198894372dbfe0f (patch) | |
tree | 777afd96a8e332d3712df0a2e26c04ed8d4c06ca /src/nvim/ex_cmds.c | |
parent | 28d5face21748bbd7b116a1e57bffb535dba392a (diff) | |
parent | d11bbacf0ffa45096364195bda4739984d25121e (diff) | |
download | rneovim-8215c05945054755b2c3cadae198894372dbfe0f.tar.gz rneovim-8215c05945054755b2c3cadae198894372dbfe0f.tar.bz2 rneovim-8215c05945054755b2c3cadae198894372dbfe0f.zip |
Merge pull request #17194 from zeertzjq/inccommand-prev-sub
fix(inccommand): do not change reg_prev_sub when previewing
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 1916fa7e44..3b3d4e50cc 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3652,8 +3652,14 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // We do it here once to avoid it to be replaced over and over again. // But don't do it when it starts with "\=", then it's an expression. assert(sub != NULL); + + bool sub_needs_free = false; if (!(sub[0] == '\\' && sub[1] == '=')) { + char_u *source = sub; sub = regtilde(sub, p_magic); + // When previewing, the new pattern allocated by regtilde() needs to be freed + // in this function because it will not be used or freed by regtilde() later. + sub_needs_free = preview && sub != source; } // Check for a match on each line. @@ -4450,6 +4456,10 @@ skip: kv_destroy(preview_lines.subresults); + if (sub_needs_free) { + xfree(sub); + } + return preview_buf; #undef ADJUST_SUB_FIRSTLNUM #undef PUSH_PREVIEW_LINES |