From: Max Kellermann Date: Thu, 27 Nov 2008 15:58:14 +0000 (+0100) Subject: list_window: fixed endless loop in non-wrapped search X-Git-Tag: v0.12_beta2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f7d53b74a7743e120f9f1019c594cbd2de708caf;p=ncmpc.git 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. --- 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; }