svn commit: r1932956 - subversion/trunk/subversion/svnbrowse

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <177581608415.1356679.17057677637740477075@svn03-he-fi>
Author: rinrab
Date: Fri Apr 10 10:14:43 2026
New Revision: 1932956

Log:
svnbrowse: When going up a directory, select the recently visited node in the
list.

* subversion/svnbrowse/model.c
  (svn_browse__model_go_up): Loop through all items in the list to find the
   node with the same matching name as the name we obtained from
   svn_relpath_split(). In case if no items were found with this name (which is
   possible as it could be deleted by now), just select the first element.
* subversion/svnbrowse/svnbrowse.c
  (view_on_event): Center the view after executing go_up action; The exact same
   code as in 'z' handling.

Modified:
   subversion/trunk/subversion/svnbrowse/model.c
   subversion/trunk/subversion/svnbrowse/svnbrowse.c

Modified: subversion/trunk/subversion/svnbrowse/model.c
==============================================================================
--- subversion/trunk/subversion/svnbrowse/model.c	Fri Apr 10 10:01:25 2026	(r1932955)
+++ subversion/trunk/subversion/svnbrowse/model.c	Fri Apr 10 10:14:43 2026	(r1932956)
@@ -165,10 +165,27 @@ svn_browse__model_go_enter(svn_browse__m
 svn_error_t *
 svn_browse__model_go_up(svn_browse__model_t *model, apr_pool_t *scratch_pool)
 {
-  const char *new_url = svn_relpath_dirname(model->current->relpath,
-                                            scratch_pool);
-  return svn_error_trace(svn_browse__model_enter_path(model, new_url,
-                                                      scratch_pool));
+  const char *dirpath, *name;
+  int i;
+
+  svn_relpath_split(&dirpath, &name, model->current->relpath, scratch_pool);
+
+  SVN_ERR(svn_browse__model_enter_path(model, dirpath, scratch_pool));
+
+  /* find previously visited node in the list to select it as we go a dir up */
+  for (i = 0; i < model->current->list->nelts; i++)
+    {
+      svn_browse__item_t *item = APR_ARRAY_IDX(model->current->list, i,
+                                               svn_browse__item_t *);
+
+      if (strcmp(item->name, name) == 0)
+        {
+          model->current->selection = i;
+          break;
+        }
+    }
+
+  return SVN_NO_ERROR;
 }
 
 svn_error_t *

Modified: subversion/trunk/subversion/svnbrowse/svnbrowse.c
==============================================================================
--- subversion/trunk/subversion/svnbrowse/svnbrowse.c	Fri Apr 10 10:01:25 2026	(r1932955)
+++ subversion/trunk/subversion/svnbrowse/svnbrowse.c	Fri Apr 10 10:14:43 2026	(r1932956)
@@ -158,6 +158,8 @@ view_on_event(svn_browse__view_t *view,
       case '-':
       case 'u':
         SVN_ERR(svn_browse__model_go_up(view->model, scratch_pool));
+        view->model->current->scroller_offset =
+            view->model->current->selection - scrollsize / 2;
         break;
       case CTRL('e'):
         view->model->current->scroller_offset += 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.