{
int address_count = 1;
linenr_T lnum;
+ int need_check_cursor = FALSE;
+ int ret = FAIL;
// Repeat for all ',' or ';' separated addresses.
for (;;)
lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
eap->addr_count == 0, address_count++);
if (eap->cmd == NULL) // error detected
- return FAIL;
+ goto theend;
if (lnum == MAXLNUM)
{
if (*eap->cmd == '%') // '%' - all lines
// there is no Vim command which uses '%' and
// ADDR_WINDOWS or ADDR_TABS
*errormsg = _(e_invalid_range);
- return FAIL;
+ goto theend;
}
break;
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
case ADDR_QUICKFIX:
*errormsg = _(e_invalid_range);
- return FAIL;
+ goto theend;
case ADDR_ARGUMENTS:
if (ARGCOUNT == 0)
eap->line1 = eap->line2 = 0;
if (eap->addr_type != ADDR_LINES)
{
*errormsg = _(e_invalid_range);
- return FAIL;
+ goto theend;
}
++eap->cmd;
{
fp = getmark('<', FALSE);
if (check_mark(fp) == FAIL)
- return FAIL;
+ goto theend;
eap->line1 = fp->lnum;
fp = getmark('>', FALSE);
if (check_mark(fp) == FAIL)
- return FAIL;
+ goto theend;
eap->line2 = fp->lnum;
++eap->addr_count;
}
if (!eap->skip)
{
curwin->w_cursor.lnum = eap->line2;
+
// Don't leave the cursor on an illegal line or column, but do
// accept zero as address, so 0;/PATTERN/ works correctly.
+ // Check the cursor position before returning.
if (eap->line2 > 0)
check_cursor();
+ need_check_cursor = TRUE;
}
}
else if (*eap->cmd != ',')
if (lnum == MAXLNUM)
eap->addr_count = 0;
}
- return OK;
+ ret = OK;
+
+theend:
+ if (need_check_cursor)
+ check_cursor();
+ return ret;
}
/*