vim-patch:8.1.1261: no error for quickfix commands with negative range

Problem:    No error for quickfix commands with negative range.
Solution:   Add ADDR_UNSIGNED and use it for quickfix commands.  Make
            assert_fails() show the command if the error doesn't match.
25190db225

N/A patches for version.c:

vim-patch:8.2.0113: "make cmdidxs" fails

Problem:    "make cmdidxs" fails.
Solution:   Allow address for ":cquit".  Add --not-a-term to avoid a delay.
9b24dfcb9f
This commit is contained in:
erw7
2020-10-13 10:02:36 +09:00
committed by Jan Edmund Lazo
parent a66d63f36e
commit 35dc6d6e87
8 changed files with 165 additions and 69 deletions

View File

@@ -1383,6 +1383,10 @@ static char_u * do_one_cmd(char_u **cmdlinep,
if (ea.cmdidx == CMD_wincmd && p != NULL) {
get_wincmd_addr_type(skipwhite(p), &ea);
}
// :.cc in quickfix window uses line number
if ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf)) {
ea.addr_type = ADDR_OTHER;
}
}
ea.cmd = cmd;
@@ -1730,14 +1734,17 @@ static char_u * do_one_cmd(char_u **cmdlinep,
ea.line2 = ARGCOUNT;
}
break;
case ADDR_QUICKFIX:
ea.line2 = qf_get_size(&ea);
case ADDR_QUICKFIX_VALID:
ea.line2 = qf_get_valid_size(&ea);
if (ea.line2 == 0) {
ea.line2 = 1;
}
break;
case ADDR_NONE:
IEMSG(_("INTERNAL: Cannot use DFLALL with ADDR_NONE"));
case ADDR_UNSIGNED:
case ADDR_QUICKFIX:
IEMSG(_("INTERNAL: Cannot use DFLALL "
"with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX"));
break;
}
}
@@ -2347,9 +2354,13 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
eap->line2 = CURRENT_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
eap->line2 = 1;
break;
case ADDR_QUICKFIX:
eap->line2 = qf_get_cur_idx(eap);
break;
case ADDR_QUICKFIX_VALID:
eap->line2 = qf_get_cur_valid_idx(eap);
break;
case ADDR_NONE:
@@ -2403,6 +2414,8 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
}
break;
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
case ADDR_QUICKFIX:
*errormsg = (char_u *)_(e_invrange);
return FAIL;
case ADDR_ARGUMENTS:
@@ -2413,9 +2426,9 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
eap->line2 = ARGCOUNT;
}
break;
case ADDR_QUICKFIX:
case ADDR_QUICKFIX_VALID:
eap->line1 = 1;
eap->line2 = qf_get_size(eap);
eap->line2 = qf_get_valid_size(eap);
if (eap->line2 == 0) {
eap->line2 = 1;
}
@@ -2524,14 +2537,13 @@ static void append_command(char_u *cmd)
*d = NUL;
}
/*
* Find an Ex command by its name, either built-in or user.
* Start of the name can be found at eap->cmd.
* Returns pointer to char after the command name.
* "full" is set to TRUE if the whole command name matched.
* Returns NULL for an ambiguous user command.
*/
// Find an Ex command by its name, either built-in or user.
// Start of the name can be found at eap->cmd.
// Sets eap->cmdidx and returns a pointer to char after the command name.
// "full" is set to TRUE if the whole command name matched.
// Returns NULL for an ambiguous user command.
static char_u *find_command(exarg_T *eap, int *full)
FUNC_ATTR_NONNULL_ARG(1)
{
int len;
char_u *p;
@@ -3761,11 +3773,15 @@ static linenr_T get_address(exarg_T *eap,
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_UNSIGNED:
EMSG(_(e_invrange));
cmd = NULL;
goto error;
break;
case ADDR_QUICKFIX:
lnum = qf_get_cur_idx(eap);
break;
case ADDR_QUICKFIX_VALID:
lnum = qf_get_cur_valid_idx(eap);
break;
}
@@ -3802,6 +3818,7 @@ static linenr_T get_address(exarg_T *eap,
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_UNSIGNED:
EMSG(_(e_invrange));
cmd = NULL;
goto error;
@@ -3812,6 +3829,12 @@ static linenr_T get_address(exarg_T *eap,
lnum = 1;
}
break;
case ADDR_QUICKFIX_VALID:
lnum = qf_get_valid_size(eap);
if (lnum == 0) {
lnum = 1;
}
break;
}
break;
@@ -3964,9 +3987,14 @@ static linenr_T get_address(exarg_T *eap,
lnum = 1;
break;
case ADDR_QUICKFIX:
lnum = qf_get_cur_idx(eap);
break;
case ADDR_QUICKFIX_VALID:
lnum = qf_get_cur_valid_idx(eap);
break;
case ADDR_NONE:
case ADDR_UNSIGNED:
lnum = 0;
break;
}
}
@@ -4115,7 +4143,19 @@ static char_u *invalid_range(exarg_T *eap)
break;
case ADDR_QUICKFIX:
assert(eap->line2 >= 0);
if (eap->line2 != 1 && (size_t)eap->line2 > qf_get_size(eap)) {
// No error for value that is too big, will use the last entry.
if (eap->line2 <= 0) {
return (char_u *)_(e_invrange);
}
break;
case ADDR_QUICKFIX_VALID:
if ((eap->line2 != 1 && (size_t)eap->line2 > qf_get_valid_size(eap))
|| eap->line2 < 0) {
return (char_u *)_(e_invrange);
}
break;
case ADDR_UNSIGNED:
if (eap->line2 < 0) {
return (char_u *)_(e_invrange);
}
break;