Code

list_window: reset cursor when list is empty
authorMax Kellermann <max@duempel.org>
Tue, 25 Nov 2008 17:44:42 +0000 (18:44 +0100)
committerMax Kellermann <max@duempel.org>
Tue, 25 Nov 2008 17:44:42 +0000 (18:44 +0100)
Due to a side effect of the old "if" condition, the cursor was never
reset to the origin when the list was cleared.

src/list_window.c

index efb610117231d92812c8654b7234ebcb54ad0484..9f34f539fc6d212dfcfdff9643611128bab8238a 100644 (file)
@@ -73,7 +73,9 @@ list_window_check_selected(struct list_window *lw, unsigned length)
        if (lw->selected < lw->start)
                lw->selected = lw->start;
 
-       if (length > 0 && lw->selected >= length)
+       if (length == 0)
+               lw->selected = 0;
+       else if (lw->selected >= length)
                lw->selected = length - 1;
 }