Commit Diff


commit - d2b2612ba9fbd6549248a3bb347f15672b2c7915
commit + 05de8ac36a0646bbcf74d36b25b96244ac1290ff
blob - 3d737a1f4f8e1e94d14ea6b63705227c91b032d6
blob + e7100358e688c1795ce9e52a2ec0aafd1d6c4e4f
--- cmd.c
+++ cmd.c
@@ -459,7 +459,7 @@ cmd_tab_close(struct buffer *buffer)
 	if ((t = TAILQ_NEXT(tab, tabs)) != NULL ||
 	    (t = TAILQ_PREV(tab, tabshead, tabs)) != NULL) {
 		switch_to_tab(t);
-		kill_tab(tab);
+		kill_tab(tab, 0);
 	} else
 		message("Can't close the only tab.");
 
@@ -474,7 +474,7 @@ cmd_tab_close_other(struct buffer *buffer)
 		if (t == current_tab)
 			continue;
 
-		kill_tab(t);
+		kill_tab(t, 0);
 	}
 }
 
blob - 5c1884239de6e87e87bd280a63ec1e79923404c9
blob + bdf7e8b6ce3ff81541ab1fae0ee2f6d0afabea25
--- session.c
+++ session.c
@@ -85,10 +85,13 @@ new_tab(const char *url, const char *base, struct tab 
 
 /*
  * Move a tab from the tablist to the killed tab list and erase its
- * contents.  NB: doesn't update the current_tab.
+ * contents.  Append should always be 0 to prepend tabs so unkill_tab
+ * can work correctly; appending is only useful during startup when
+ * receiving the list of killed tabs to keep the correct order.
+ * NB: doesn't update the current_tab.
  */
 void
-kill_tab(struct tab *tab)
+kill_tab(struct tab *tab, int append)
 {
 	int count;
 
@@ -101,7 +104,10 @@ kill_tab(struct tab *tab)
 	if (evtimer_pending(&tab->loadingev, NULL))
 		evtimer_del(&tab->loadingev);
 
-	TAILQ_INSERT_HEAD(&ktabshead, tab, tabs);
+	if (append)
+		TAILQ_INSERT_TAIL(&ktabshead, tab, tabs);
+	else
+		TAILQ_INSERT_HEAD(&ktabshead, tab, tabs);
 
 	/* gc closed tabs */
 	count = 0;
blob - 27af81e3dc4e84f9178b54b4636499d516f6cc25
blob + f3dad28535b6cdf3067255a39b283eefaea162a7
--- session.h
+++ session.h
@@ -33,7 +33,7 @@ struct session_tab_hist {
 void		 switch_to_tab(struct tab *);
 unsigned int	 tab_new_id(void);
 struct tab	*new_tab(const char *, const char *base, struct tab *);
-void		 kill_tab(struct tab *);
+void		 kill_tab(struct tab *, int);
 struct tab	*unkill_tab(void);
 void		 free_tab(struct tab *);
 void		 stop_tab(struct tab*);
blob - 7dac83364bc3bc2eea62d67b52a8b09862b41ec4
blob + 264dc170274cd609fe4ad1980614eda5c06e3937
--- telescope.c
+++ telescope.c
@@ -528,7 +528,7 @@ handle_imsg_session(struct imsg *imsg, size_t datalen)
 		if (st.flags & TAB_CURRENT)
 			curr = tab;
 		if (st.flags & TAB_KILLED)
-			kill_tab(tab);
+			kill_tab(tab, 1);
 		break;
 
 	case IMSG_SESSION_TAB_HIST: