From f7d53b74a7743e120f9f1019c594cbd2de708caf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 27 Nov 2008 16:58:14 +0100 Subject: [PATCH] list_window: fixed endless loop in non-wrapped search When the cursor was at the end of a list and the user pressed 'n', ncmpc would hang in an endless loop forever. The same bug was fixed in the backwards search. --- src/list_window.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/list_window.c b/src/list_window.c index 9f34f53..46858ee 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -221,7 +221,7 @@ list_window_find(struct list_window *lw, unsigned i = lw->selected + 1; const char *label; - while (wrap || i == lw->selected + 1) { + do { while ((label = callback(i,&h,callback_data))) { if (str && label && strcasestr(label, str)) { lw->selected = i; @@ -237,7 +237,7 @@ list_window_find(struct list_window *lw, i=0; /* first item */ screen_bell(); } - } + } while (wrap); return 1; } @@ -257,7 +257,7 @@ list_window_rfind(struct list_window *lw, if (rows == 0) return 1; - while (wrap || i == (int)lw->selected - 1) { + do { while (i >= 0 && (label = callback(i,&h,callback_data))) { if( str && label && strcasestr(label, str) ) { lw->selected = i; @@ -271,7 +271,8 @@ list_window_rfind(struct list_window *lw, i = rows - 1; /* last item */ screen_bell(); } - } + } while (wrap); + return 1; } -- 2.30.2