From bdb2f762cf335e621d9bd2556f5f92306ecf4201 Mon Sep 17 00:00:00 2001
From: Alexander Schwinn <alexxcons@xfce.org>
Date: Sat, 5 Jun 2021 00:47:27 +0200
Subject: [PATCH] Fix missing folder in history when opened in new tab (Issue
 #594)

Fixes #594
---
 thunar/thunar-history.c | 17 +++++++++++++++++
 thunar/thunar-history.h |  2 ++
 thunar/thunar-window.c  | 12 ++++++++++--
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/thunar/thunar-history.c b/thunar/thunar-history.c
index f4c83d006..aa81d9319 100644
--- a/thunar/thunar-history.c
+++ b/thunar/thunar-history.c
@@ -723,3 +723,20 @@ thunar_history_peek_forward (ThunarHistory *history)
 
   return result;
 }
+
+
+
+/**
+ * thunar_history_add:
+ * @history : a #ThunarHistory
+ * @directory : a #ThunarFile
+ *
+ * Manually adds the passed directory to the history
+ **/
+void
+thunar_history_add (ThunarHistory *history,
+                    ThunarFile    *directory)
+{
+  thunar_history_set_current_directory (THUNAR_NAVIGATOR (history), directory);
+}
+
diff --git a/thunar/thunar-history.h b/thunar/thunar-history.h
index ffae36e06..a6a999ddb 100644
--- a/thunar/thunar-history.h
+++ b/thunar/thunar-history.h
@@ -63,6 +63,8 @@ void            thunar_history_action_forward   (ThunarHistory         *history)
 void            thunar_history_show_menu        (ThunarHistory         *history,
                                                  ThunarHistoryMenuType  type,
                                                  GtkWidget             *parent);
+void            thunar_history_add              (ThunarHistory         *history,
+                                                 ThunarFile            *directory);
 
 G_END_DECLS;
 
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index b234fd34d..ab3d855e8 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1978,7 +1978,13 @@ thunar_window_notebook_insert (ThunarWindow  *window,
 
   /* set the history of the view if a history is provided */
   if (history != NULL)
-    thunar_standard_view_set_history (THUNAR_STANDARD_VIEW (view), history);
+    {
+      /* history only is updated on 'change-directory' signal. */
+      /* For inserting a new tab, we need to update it manually */
+      thunar_history_add (history, directory);
+
+      thunar_standard_view_set_history (THUNAR_STANDARD_VIEW (view), history);
+    }
 
   label_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
@@ -2033,7 +2039,9 @@ thunar_window_notebook_open_new_tab (ThunarWindow *window,
 
   /* save the history of the current view */
   if (THUNAR_IS_STANDARD_VIEW (window->view))
-    history = thunar_standard_view_copy_history (THUNAR_STANDARD_VIEW (window->view));
+    {
+      history = thunar_standard_view_copy_history (THUNAR_STANDARD_VIEW (window->view));
+    }
 
   /* find the correct view type */
   view_type = thunar_window_view_type_for_directory (window, directory);
-- 
GitLab