summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/input.rst2
-rw-r--r--player/command.c7
2 files changed, 4 insertions, 5 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index b0a7ed2a2e..05cc9da562 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -419,7 +419,7 @@ Input Commands that are Possibly Subject to Change
The special argument ``!reverse`` can be used to cycle the value list in
reverse. Compared with a command that just lists the value in reverse, this
command will actually share the internal counter with the forward-cycling
- key binding.
+ key binding (as long as the rest of the arguments are the same).
Note that there is a static limit of (as of this writing) 10 arguments
(this limit could be raised on demand).
diff --git a/player/command.c b/player/command.c
index 09fb75433a..c9f7f18d22 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3650,7 +3650,7 @@ static int *get_cmd_cycle_counter(struct MPContext *mpctx, char **args)
if (stringlist_equals(ctr->args, args))
return &ctr->counter;
}
- struct cycle_counter ctr = {stringlist_dup(cmd, args), 0};
+ struct cycle_counter ctr = {stringlist_dup(cmd, args), -1};
MP_TARRAY_APPEND(cmd, cmd->cycle_counters, cmd->num_cycle_counters, ctr);
return &cmd->cycle_counters[cmd->num_cycle_counters - 1].counter;
}
@@ -3840,14 +3840,13 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
int *ptr = get_cmd_cycle_counter(mpctx, &args[first - 1]);
int count = cmd->nargs - first;
if (ptr && count > 0) {
- int next = *ptr;
- *ptr += dir;
+ *ptr = *ptr < 0 ? (dir > 0 ? 0 : -1) : *ptr + dir;
if (*ptr >= count)
*ptr = 0;
if (*ptr < 0)
*ptr = count - 1;
char *property = args[first - 1];
- char *value = args[first + next];
+ char *value = args[first + *ptr];
int r = mp_property_do(property, M_PROPERTY_SET_STRING, value, mpctx);
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, property, on_osd);