don't change the path bar value if the new path is a prefix of the current path

Tue, 30 Jan 2024 11:58:11 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 30 Jan 2024 11:58:11 +0100
changeset 12
3eb0cbab53db
parent 11
26acbfa75c1f
child 13
5a8762fcfecc

don't change the path bar value if the new path is a prefix of the current path

application/davcontroller.c file | annotate | diff | comparison | revisions
--- a/application/davcontroller.c	Tue Jan 30 09:10:05 2024 +0100
+++ b/application/davcontroller.c	Tue Jan 30 11:58:11 2024 +0100
@@ -123,14 +123,19 @@
     if (len == 1 && *path == '/') {
         path = "";
     }
+    
+    // check if the new path is a prefix of the current path
+    // if not, we have to set the pathbar string to the new path
     char *full_path = util_concat_path(browser->repo_base, path);
-    // compare new path with current path
-    // in theory we could always set path, but maybe this is faster
+    char *full_path_col = util_concat_path(full_path, "/");
     char *current_path = ui_get(browser->path);
-    if (strcmp(full_path, current_path)) {
+    cxstring cpath = cx_str(current_path);
+    cxstring newc = cx_str(full_path_col);
+    if (!cx_strprefix(cpath, newc)) {
         ui_set(browser->path, full_path);
     }
     free(full_path);
+    free(full_path_col);
 
     DavBrowserQueryPath *query = malloc(sizeof(DavBrowserQueryPath));
     query->pool = browser->dav_queue;

mercurial