patch 9.1.0574: ex: wrong handling of commands after bar Commit: https://github.com/vim/vim/commit/8c446da34998f6350911e07fbfd7932412c83185 Author: Mohamed Akram <mohd.ak...@outlook.com> Date: Sat Jul 13 18:49:55 2024 +0200
patch 9.1.0574: ex: wrong handling of commands after bar Problem: ex: wrong handling of commands after bar Solution: for :append, :insert and :change use the text after the bar as input for those commands. This is what POSIX requests. (Mohamed Akram) See the POSIX Spec: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_13_03 Section 12.c closes: #15229 Signed-off-by: Mohamed Akram <mohd.ak...@outlook.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 08bf4f327..d48018f58 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 9.1. Last change: 2024 Jul 12 +*insert.txt* For Vim version 9.1. Last change: 2024 Jul 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1995,6 +1995,16 @@ These two commands will keep on asking for lines, until you type a line containing only a ".". Watch out for lines starting with a backslash, see |line-continuation|. +Text typed after a "|" command separator is used first. So the following +command in ex mode: > + :a|one + two + . + :visual +<appends the following text, after the cursor line: > + one + two +< NOTE: These commands cannot be used with |:global| or |:vglobal|. ":append" and ":insert" don't work properly in between ":if" and ":endif", ":for" and ":endfor", ":while" and ":endwhile". diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 8143c2406..c36593798 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3360,7 +3360,13 @@ ex_append(exarg_T *eap) indent = get_indent_lnum(lnum); } ex_keep_indent = FALSE; - if (eap->ea_getline == NULL) + if (*eap->arg == '|') + { + // Get the text after the trailing bar. + theline = vim_strsave(eap->arg + 1); + *eap->arg = NUL; + } + else if (eap->ea_getline == NULL) { // No getline() function, use the lines that follow. This ends // when there is no more. diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 7ab1c69e5..614ba2080 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5401,7 +5401,11 @@ separate_nextcmd(exarg_T *eap, int keep_backslash) && in_vim9script() && !(eap->argt & EX_NOTRLCOM) && p > eap->cmd && VIM_ISWHITE(p[-1])) - || *p == '|' || *p == ' ') + || (*p == '|' + && eap->cmdidx != CMD_append + && eap->cmdidx != CMD_change + && eap->cmdidx != CMD_insert) + || *p == ' ') { /* * We remove the '\' before the '|', unless EX_CTRLV is used diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim index b0e5d81a8..c4f82d33c 100644 --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -364,4 +364,12 @@ func Test_implicit_print() bw! endfunc +" Test inserting text after the trailing bar +func Test_insert_after_trailing_bar() + new + call feedkeys("Qi| foo . a|bar bar . c|baz .", "xt") + call assert_equal(['', 'foo', 'bar', 'baz'], getline(1, '$')) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index a4ae10f20..25e38ca55 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 574, /**/ 573, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1sTxuk-0091AO-4W%40256bit.org.