diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-25 19:29:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-25 19:29:30 +0200 |
commit | f3d30842dcc8ef4134da462bd4197ae2e2c6c0c1 (patch) | |
tree | 9f00a98b9076f88ea37a5e1c0560ddc54e4b1424 | |
parent | b420ac9d20d484ba0ebf3e328069251a63f96996 (diff) | |
download | vim-git-f3d30842dcc8ef4134da462bd4197ae2e2c6c0c1.tar.gz |
patch 8.2.3047: increment and decrement don't allow for next commandv8.2.3047
Problem: Increment and decrement don't allow for next command.
Solution: Allow for comment and next command. (closes #8442)
-rw-r--r-- | src/ex_cmds.h | 4 | ||||
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9script.c | 8 |
4 files changed, 14 insertions, 4 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 8ddac37b5..ef3fa669c 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -1875,10 +1875,10 @@ EXCMD(CMD_X, "X", ex_X, // 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, + EX_EXTRA|EX_TRLBAR|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, + EX_EXTRA|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, ADDR_NONE), #undef EXCMD diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 1d3c20e9f..a26867f59 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1889,6 +1889,10 @@ def Test_inc_dec() 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] diff --git a/src/version.c b/src/version.c index 1ecb56771..3898725e7 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3047, +/**/ 3046, /**/ 3045, diff --git a/src/vim9script.c b/src/vim9script.c index 7078cbe9c..7c6526b65 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -166,19 +166,23 @@ vim9_comment_start(char_u *p) ex_incdec(exarg_T *eap) { char_u *cmd = eap->cmd; - size_t len = STRLEN(eap->cmd) + 6; + 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, + 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; } /* |