Mercurial > vim
comparison src/vim9script.c @ 24533:9c404d78d767 v8.2.2806
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Commit: https://github.com/vim/vim/commit/bdc0f1c6986e5d64f647e0924a4de795b47c549a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 24 19:08:24 2021 +0200
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Problem: Vim9: using "++nr" as a command might not work.
Solution: Do not recognize "++" and "--" in a following line as addition or
subtraction.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 24 Apr 2021 19:15:04 +0200 |
parents | 3bfec39ce31c |
children | bf8feac8a89a |
comparison
equal
deleted
inserted
replaced
24532:7660cdae6683 | 24533:9c404d78d767 |
---|---|
156 { | 156 { |
157 return p[0] == '#' && (p[1] != '{' || p[2] == '{'); | 157 return p[0] == '#' && (p[1] != '{' || p[2] == '{'); |
158 } | 158 } |
159 | 159 |
160 #if defined(FEAT_EVAL) || defined(PROTO) | 160 #if defined(FEAT_EVAL) || defined(PROTO) |
161 | |
162 /* | |
163 * "++nr" and "--nr" commands. | |
164 */ | |
165 void | |
166 ex_incdec(exarg_T *eap) | |
167 { | |
168 char_u *cmd = eap->cmd; | |
169 size_t len = STRLEN(eap->cmd) + 6; | |
170 | |
171 // This works like "nr += 1" or "nr -= 1". | |
172 eap->cmd = alloc(len); | |
173 if (eap->cmd == NULL) | |
174 return; | |
175 vim_snprintf((char *)eap->cmd, len, "%s %c= 1", cmd + 2, | |
176 eap->cmdidx == CMD_increment ? '+' : '-'); | |
177 eap->arg = eap->cmd; | |
178 eap->cmdidx = CMD_var; | |
179 ex_let(eap); | |
180 vim_free(eap->cmd); | |
181 eap->cmd = cmd; | |
182 } | |
161 | 183 |
162 /* | 184 /* |
163 * ":export let Name: type" | 185 * ":export let Name: type" |
164 * ":export const Name: type" | 186 * ":export const Name: type" |
165 * ":export def Name(..." | 187 * ":export def Name(..." |