shithub: zuke

Download patch

ref: 73d9cb94c73a8c264cb3f6834828985bd15556d5
parent: eac2af266c6a009cee2d49dfb3e2165736ea6406
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Oct 12 09:00:00 EDT 2020

search: fix cycle when on first/last element in the playlist

--- a/zuke.c
+++ b/zuke.c
@@ -763,7 +763,7 @@
 		return;
 
 	cycle = 1;
-	for(i = pcur+inc; i >= 0 && i < plnum; i += inc){
+	for(i = pcur+inc; i >= 0 && i < plnum;){
 		m = getmeta(i);
 		for(a = 0; a < m->numartist; a++){
 			if(cistrstr(m->artist[a], buf) != nil)
@@ -775,18 +775,21 @@
 			break;
 		if(cistrstr(m->path, buf) != nil)
 			break;
-		if(cycle && i+inc == -1){
-			cycle = 0;
-			i = plnum;
-		}else if(cycle && i+inc == plnum){
-			cycle = 0;
-			i = -1;
-		}
+onemore:
+		i += inc;
 	}
 	if(i >= 0 && i < plnum){
 		pcur = i;
 		recenter();
 		redraw(1);
+	}else if(cycle && i+inc < 0){
+		cycle = 0;
+		i = plnum;
+		goto onemore;
+	}else if(cycle && i+inc >= plnum){
+		cycle = 0;
+		i = -1;
+		goto onemore;
 	}
 }