Code

screen_play: use mpd_cmd_delete_range()
authorMax Kellermann <max@duempel.org>
Wed, 30 Sep 2009 21:55:40 +0000 (23:55 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 30 Sep 2009 21:55:40 +0000 (23:55 +0200)
src/screen_play.c

index 3b50a12b852a14871ed13fc2087f21d42f492263..bd830bac23785ecf735d21c3bbd52da483f7c7c6 100644 (file)
@@ -663,22 +663,17 @@ play_cmd(struct mpdclient *c, command_t cmd)
                mpdclient_cmd_play(c, lw->selected);
                return true;
        case CMD_DELETE:
-       {
-               int i = lw->selected_end, start = lw->selected_start;
-               for(; i >= start; --i)
-                       mpdclient_cmd_delete(c, i);
-
-               i++;
-               if(i >= (int)playlist_length(&c->playlist))
-                       i--;
-               lw->selected = i;
-               lw->selected_start = i;
-               lw->selected_end = i;
-               lw->range_selection = false;
+               if (lw->range_selection) {
+                       mpdclient_cmd_delete_range(c, lw->selected_start,
+                                                  lw->selected_end + 1);
+               } else {
+                       mpdclient_cmd_delete(c, lw->selected);
+               }
 
-               playlist_save_selection();
+               lw->selected = lw->selected_end = lw->selected_start;
+               lw->range_selection = false;
                return true;
-       }
+
        case CMD_SAVE_PLAYLIST:
                playlist_save(c, NULL, NULL);
                return true;