shithub: zuke

Download patch

ref: 8d2b1527e5a83ba5c91191656fafb25866ec74ac
parent: ac6e12de0bdf7e46e8911baabaff9eb30ae90c5f
author: Sigrid Haflínudóttir <[email protected]>
date: Mon Oct 12 08:32:31 EDT 2020

search: cycle when not found

--- a/zuke.c
+++ b/zuke.c
@@ -741,7 +741,7 @@
 	Meta *m;
 	static char buf[64];
 	static int sz;
-	int inc, i, a;
+	int inc, i, a, cycle;
 
 	inc = (d == '/' || d == 'n') ? 1 : -1;
 	if(d == '/' || d == '?')
@@ -749,6 +749,7 @@
 	if(sz < 1)
 		return;
 
+	cycle = 1;
 	for(i = pcur+inc; i >= 0 && i < plnum; i += inc){
 		m = getmeta(i);
 		for(a = 0; a < m->numartist; a++){
@@ -761,6 +762,13 @@
 			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;
+		}
 	}
 	if(i >= 0 && i < plnum){
 		pcur = i;