shithub: hell

Download patch

ref: 47f999affea86e6e3a0322a642f29b3319d4845f
parent: 38f5995247508ae1dc33cfcf4b4e015d05bd0aba
author: penny <penny@limitedideas.org>
date: Fri Sep 26 16:37:28 EDT 2025

don't crash if we use next/prev with no page loaded

--- a/main.go
+++ b/main.go
@@ -118,12 +118,16 @@
 				hc.stats.slock.Unlock()
 				return
 			case "prev":
-				hc.page.Prev()
-				fmt.Print(hc.page.String())
+				if hc.page != nil {
+					hc.page.Prev()
+					fmt.Print(hc.page.String())
+				}
 				return
 			case "next":
-				hc.page.Next()
-				fmt.Print(hc.page.String())
+				if hc.page != nil {
+					hc.page.Next()
+					fmt.Print(hc.page.String())
+				}
 				return
 			case "bookmarks":
 				hc.pause(true)
@@ -353,11 +357,11 @@
 					accounts, err = hc.client.AccountsSearchResolve(context.Background(), index, 1, true)
 					if err != nil {
 						fmt.Printf("Error resolving account %s: %v\n", index, err)
-					return
+						return
 					}
 					if len(accounts) < 1 {
 						fmt.Printf("No account matched %s\n", index)
-					return
+						return
 					}
 					account = accounts[0]
 				}
--- a/pages.go
+++ b/pages.go
@@ -128,13 +128,14 @@
 		if i != 0 && linecount > height {
 			return
 		}
-		if i !=0 && items[i].lines == -1 {
+		//-1 lines indicates we should display this item on its own page
+		if i != 0 && items[i].lines == -1 {
 			return
 		}
 		if i == 0 && items[i].lines == -1 {
 			index++
 			return
-			}
+		}
 		index++
 	}
 	return
--