]> Sergey Matveev's repositories - nnn.git/commitdiff
Retain a way to return to start dir if file opened
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 10 Feb 2021 23:56:51 +0000 (05:26 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 10 Feb 2021 23:56:51 +0000 (05:26 +0530)
src/nnn.c

index e4f78df36d1e7ecb591b7b5321188a039d6917c1..623884733bdfbb77384f9b3b6b4b1edb0fbab2bb 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5904,6 +5904,11 @@ static bool browse(char *ipath, const char *session, int pkey)
                lastname = g_ctx[0].c_name; /* last visited filename */
 
                xstrsncpy(g_ctx[0].c_path, ipath, PATH_MAX);
+               /* If the initial path is a file, retain a way to return to start dir */
+               if (g_state.initfile) {
+                       free(initpath);
+                       initpath = ipath = getcwd(NULL, 0);
+               }
                path = g_ctx[0].c_path; /* current directory */
 
                g_ctx[0].c_fltr[0] = g_ctx[0].c_fltr[1] = '\0';