feat(ex_cmds): no error on :lua with {range} and {code} (#27290)

Problem:  Erroring when both {range} and {code} are supplied to
          :lua is inconvenient and may break mappings.
Solution: Don't error, ignore {range} and execute {code} when both
          are supplied.
This commit is contained in:
luukvbaal
2024-02-02 06:14:10 +01:00
committed by GitHub
parent 1405e5c8c1
commit 4a1ad676ce
2 changed files with 9 additions and 10 deletions

View File

@@ -1649,12 +1649,12 @@ bool nlua_is_deferred_safe(void)
void ex_lua(exarg_T *const eap)
FUNC_ATTR_NONNULL_ALL
{
// ":{range}lua"
if (eap->addr_count > 0 || *eap->arg == NUL) {
if (eap->addr_count > 0 && *eap->arg == NUL) {
// ":{range}lua", only if no {code}
if (*eap->arg == NUL) {
if (eap->addr_count > 0) {
cmd_source_buffer(eap, true);
} else {
semsg(_(e_invarg2), "exactly one of {chunk} or {range} required");
emsg(_(e_argreq));
}
return;
}