diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-23 19:45:01 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-23 19:45:01 +0000 |
commit | ac48506ac62b2ece523d5af6ea6c95b699d70b94 (patch) | |
tree | 15f7b8ac648f36039c06b1ac67f1067ce988f0eb | |
parent | c20e46a4e3efcd408ef132872238144ea34f7ae5 (diff) | |
download | vim-git-ac48506ac62b2ece523d5af6ea6c95b699d70b94.tar.gz |
patch 8.2.4615: mapping with escaped bar does not work in :def functionv8.2.4615
Problem: Mapping with escaped bar does not work in :def function. (Sergey
Vlasov)
Solution: Do not remove the backslash. (closes #10002)
-rw-r--r-- | src/ex_docmd.c | 14 | ||||
-rw-r--r-- | src/proto/ex_docmd.pro | 2 | ||||
-rw-r--r-- | src/syntax.c | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 15 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9cmds.c | 2 |
6 files changed, 27 insertions, 10 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index c33dcbca0..a35924a57 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2275,7 +2275,7 @@ do_one_cmd( */ if ((ea.argt & EX_TRLBAR) && !ea.usefilter) { - separate_nextcmd(&ea); + separate_nextcmd(&ea, FALSE); } else if (ea.cmdidx == CMD_bang || ea.cmdidx == CMD_terminal @@ -5081,9 +5081,10 @@ repl_cmdline( /* * Check for '|' to separate commands and '"' to start comments. + * If "keep_backslash" is TRUE do not remove any backslash. */ void -separate_nextcmd(exarg_T *eap) +separate_nextcmd(exarg_T *eap, int keep_backslash) { char_u *p; @@ -5097,7 +5098,7 @@ separate_nextcmd(exarg_T *eap) { if (*p == Ctrl_V) { - if (eap->argt & (EX_CTRLV | EX_XFILE)) + if ((eap->argt & (EX_CTRLV | EX_XFILE)) || keep_backslash) ++p; // skip CTRL-V and next char else // remove CTRL-V and skip next char @@ -5144,8 +5145,11 @@ separate_nextcmd(exarg_T *eap) if ((vim_strchr(p_cpo, CPO_BAR) == NULL || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') { - STRMOVE(p - 1, p); // remove the '\' - --p; + if (!keep_backslash) + { + STRMOVE(p - 1, p); // remove the '\' + --p; + } } else { diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro index 3be747107..40f264982 100644 --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -26,7 +26,7 @@ long excmd_get_argt(cmdidx_T idx); char_u *skip_range(char_u *cmd_start, int skip_star, int *ctx); void ex_ni(exarg_T *eap); int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp); -void separate_nextcmd(exarg_T *eap); +void separate_nextcmd(exarg_T *eap, int keep_backslash); char_u *skip_cmd_arg(char_u *p, int rembs); int get_bad_opt(char_u *p, exarg_T *eap); int ends_excmd(int c); diff --git a/src/syntax.c b/src/syntax.c index 6683d2a3e..74687cb4d 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -4764,7 +4764,7 @@ syn_cmd_include(exarg_T *eap, int syncing UNUSED) * filename to include. */ eap->argt |= (EX_XFILE | EX_NOSPC); - separate_nextcmd(eap); + separate_nextcmd(eap, FALSE); if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg)) { // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index b15028adf..38ee7f23f 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1178,8 +1178,19 @@ def Test_map_command() nnoremap <F3> :echo 'hit F3 #'<CR> assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n")) END - v9.CheckDefSuccess(lines) - v9.CheckScriptSuccess(['vim9script'] + lines) + v9.CheckDefAndScriptSuccess(lines) + + # backslash before bar is not removed + lines =<< trim END + vim9script + + def Init() + noremap <buffer> <F5> <ScriptCmd>MyFunc('a') \| MyFunc('b')<CR> + enddef + Init() + unmap <buffer> <F5> + END + v9.CheckScriptSuccess(lines) enddef def Test_normal_command() diff --git a/src/version.c b/src/version.c index ad4f3c813..dd2330e4a 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4615, +/**/ 4614, /**/ 4613, diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 072a106a5..483b1f34b 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1848,7 +1848,7 @@ compile_exec(char_u *line_arg, exarg_T *eap, cctx_T *cctx) if ((argt & EX_TRLBAR) && !usefilter) { eap->argt = argt; - separate_nextcmd(eap); + separate_nextcmd(eap, TRUE); if (eap->nextcmd != NULL) nextcmd = eap->nextcmd; } |