diff --git a/apps/playlist.c b/apps/playlist.c index c64fc229b5..3eb0949cc2 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -855,14 +855,14 @@ static int directory_search_callback(char* filename, void* context) if (insert_pos < 0) return -1; - + (c->count)++; - - /* Make sure tracks are inserted in correct order if user requests - INSERT_FIRST */ - if (c->position == PLAYLIST_INSERT_FIRST || c->position >= 0) - c->position = insert_pos + 1; - + + /* After first INSERT_FIRST switch to INSERT so that all the + rest of the tracks get inserted one after the other */ + if (c->position == PLAYLIST_INSERT_FIRST) + c->position = PLAYLIST_INSERT; + if (((c->count)%PLAYLIST_DISPLAY_COUNT) == 0) { unsigned char* count_str; @@ -3179,7 +3179,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, const char *filenam result = -1; break; } - + insert_pos = add_track_to_playlist(playlist, trackname, position, queue, -1); @@ -3189,13 +3189,13 @@ int playlist_insert_playlist(struct playlist_info* playlist, const char *filenam break; } - /* Make sure tracks are inserted in correct order if user - requests INSERT_FIRST */ - if (position == PLAYLIST_INSERT_FIRST || position >= 0) - position = insert_pos + 1; + /* After first INSERT_FIRST switch to INSERT so that all the + rest of the tracks get inserted one after the other */ + if (position == PLAYLIST_INSERT_FIRST) + position = PLAYLIST_INSERT; count++; - + if ((count%PLAYLIST_DISPLAY_COUNT) == 0) { display_playlist_count(count, count_str, false); diff --git a/apps/tagtree.c b/apps/tagtree.c index f006baa581..97e0c67b62 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -2018,18 +2018,9 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue } } - if (position == PLAYLIST_INSERT_FIRST) - { - from = c->filesindir - 1; - to = -1; - direction = -1; - } - else - { - from = 0; - to = c->filesindir; - direction = 1; - } + from = 0; + to = c->filesindir; + direction = 1; for (i = from; i != to; i += direction) { @@ -2049,6 +2040,11 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue break; } yield(); + + if (position == PLAYLIST_INSERT_FIRST) + { + position = PLAYLIST_INSERT; + } } playlist_sync(NULL); tagcache_search_finish(&tcs);