aboutsummaryrefslogtreecommitdiffstats
path: root/src/list_window.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-27 16:58:14 +0100
committerMax Kellermann <max@duempel.org>2008-11-27 16:58:14 +0100
commitf7d53b74a7743e120f9f1019c594cbd2de708caf (patch)
tree3d9e4bc520cd09d5a14a0196f0bea6370d003439 /src/list_window.c
parent00b15acd11ec809446e2b3962ff41dec1336cf08 (diff)
downloadmpd-f7d53b74a7743e120f9f1019c594cbd2de708caf.tar.gz
mpd-f7d53b74a7743e120f9f1019c594cbd2de708caf.tar.xz
mpd-f7d53b74a7743e120f9f1019c594cbd2de708caf.zip
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.
Diffstat (limited to '')
-rw-r--r--src/list_window.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/list_window.c b/src/list_window.c
index 9f34f539f..46858ee2b 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;
}