From 495a468c756b1dca2505c557d30e73bbfb285a52 Sat, 16 Mar 2019 22:33:54 +0100 From: Alexander Schwinn Date: Sat, 16 Mar 2019 22:32:43 +0100 Subject: [PATCH] tree view jumps (scrolls) when clicking on a directory (Bug #15174) diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c index 1241bcf..01b9109 100644 --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -2531,6 +2531,7 @@ gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), &iter, path); gtk_tree_path_free (path); + path = NULL; /* collect all ThunarFiles in the path of current_directory in a List. root is on the very left side */ for (file = view->current_directory; file != NULL; file = thunar_file_get_parent (file, NULL)) @@ -2569,11 +2570,11 @@ gtk_tree_model_get (GTK_TREE_MODEL (view->model), &child_iter, THUNAR_TREE_MODEL_COLUMN_FILE, &file_in_tree, -1); if (file == file_in_tree) { + if( path != NULL ) + gtk_tree_path_free (path); g_object_unref (file_in_tree); + /* always remember latest known path, so we can set the cursor to it */ path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->model), &child_iter); - gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE); - gtk_tree_path_free (path); iter = child_iter; /* next tree level */ break; } @@ -2585,6 +2586,15 @@ } } + + if( path == NULL ) + path = thunar_tree_view_get_preferred_toplevel_path (view, view->current_directory); + + gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE); + gtk_tree_path_free (path); + + g_list_free (path_as_list); THUNAR_THREADS_LEAVE