Patch 8.2.3047
Problem: Increment and decrement don't allow for next command.
Solution: Allow for comment and next command. (closes #8442)
Files: src/ex_cmds.h, src/vim9script.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.3046/src/ex_cmds.h 2021-06-12 14:52:35.953230564 +0200
--- src/ex_cmds.h 2021-06-25 19:10:07.089589914 +0200
***************
*** 1875,1884 ****
// Commands that are recognized only in find_ex_command().
EXCMD(CMD_increment, "++", ex_incdec,
! EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_decrement, "--", ex_incdec,
! EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
#undef EXCMD
--- 1875,1884 ----
// Commands that are recognized only in find_ex_command().
EXCMD(CMD_increment, "++", ex_incdec,
! EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_decrement, "--", ex_incdec,
! EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
#undef EXCMD
*** ../vim-8.2.3046/src/vim9script.c 2021-06-12 14:52:35.953230564 +0200
--- src/vim9script.c 2021-06-25 19:27:03.471644910 +0200
***************
*** 166,184 ****
ex_incdec(exarg_T *eap)
{
char_u *cmd = eap->cmd;
! size_t len = STRLEN(eap->cmd) + 6;
// This works like "nr += 1" or "nr -= 1".
eap->cmd = alloc(len);
if (eap->cmd == NULL)
return;
! vim_snprintf((char *)eap->cmd, len, "%s %c= 1", cmd + 2,
eap->cmdidx == CMD_increment ? '+' : '-');
eap->arg = eap->cmd;
eap->cmdidx = CMD_var;
ex_let(eap);
vim_free(eap->cmd);
eap->cmd = cmd;
}
/*
--- 166,188 ----
ex_incdec(exarg_T *eap)
{
char_u *cmd = eap->cmd;
! char_u *nextcmd = eap->nextcmd;
! size_t len = STRLEN(eap->cmd) + 8;
// This works like "nr += 1" or "nr -= 1".
+ // Add a '|' to avoid looking in the next line.
eap->cmd = alloc(len);
if (eap->cmd == NULL)
return;
! vim_snprintf((char *)eap->cmd, len, "%s %c= 1 |", cmd + 2,
eap->cmdidx == CMD_increment ? '+' : '-');
eap->arg = eap->cmd;
eap->cmdidx = CMD_var;
+ eap->nextcmd = NULL;
ex_let(eap);
vim_free(eap->cmd);
eap->cmd = cmd;
+ eap->nextcmd = nextcmd;
}
/*
*** ../vim-8.2.3046/src/testdir/test_vim9_assign.vim 2021-06-21
19:43:59.146216296 +0200
--- src/testdir/test_vim9_assign.vim 2021-06-25 19:28:10.619509114 +0200
***************
*** 1889,1894 ****
--- 1889,1898 ----
assert_equal(8, nr)
--nr
assert_equal(7, nr)
+ ++nr | ++nr
+ assert_equal(9, nr)
+ ++nr # comment
+ assert_equal(10, nr)
var ll = [1, 2]
--ll[0]
*** ../vim-8.2.3046/src/version.c 2021-06-24 21:43:27.754994402 +0200
--- src/version.c 2021-06-25 19:11:13.045440568 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3047,
/**/
--
Give a man a computer program and you give him a headache,
but teach him to program computers and you give him the power
to create headaches for others for the rest of his life...
R. B. Forest
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202106251729.15PHTvmF115198%40masaka.moolenaar.net.