aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/playlist.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 16fb4693c..a2dfd0602 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1153,12 +1153,21 @@ int moveSongInPlaylist(int fd, int from, int to)
return -1;
}
- if (to < 0 || to >= playlist.length) {
+ if ((to >= 0 && to >= playlist.length) ||
+ (to < 0 && abs(to) > playlist.length)) {
commandError(fd, ACK_ERROR_NO_EXIST,
"song doesn't exist: \"%i\"", to);
return -1;
}
+ /*
+ * (to < 0) => move to offset from current song
+ * (-playlist.length == to) => move to position BEFORE current song
+ */
+ if (to < 0 && playlist.current >= 0)
+ to = (playlist.order[playlist.current] + abs(to)) %
+ playlist.length;
+
if (playlist_state == PLAYLIST_STATE_PLAY) {
if (playlist.queued >= 0) {
queuedSong = playlist.order[playlist.queued];