]> Sergey Matveev's repositories - nnn.git/commitdiff
Simplify cd
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 May 2020 13:45:40 +0000 (19:15 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 May 2020 13:45:40 +0000 (19:15 +0530)
src/nnn.c

index 00860c351f96f8e21a340ee65ebcfe57eac84b62..aedc79b46d79cff72ae094ea1a66e12afab712f4 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5461,6 +5461,16 @@ nochange:
                        mkpath(path, dents[cur].name, newpath);
                        DPRINTF_S(newpath);
 
+                       if (dents[cur].flags & DIR_OR_LINK_TO_DIR) {
+                               if (chdir(newpath) == -1) {
+                                       printwarn(&presel);
+                                       goto nochange;
+                               }
+
+                               cdprep(lastdir, lastname, path, newpath) ? (presel = FILTER) : (watch = TRUE);
+                               goto begin;
+                       }
+
                        /* Cannot use stale data in entry, file may be missing by now */
                        if (stat(newpath, &sb) == -1) {
                                printwarn(&presel);
@@ -5469,14 +5479,6 @@ nochange:
                        DPRINTF_U(sb.st_mode);
 
                        switch (sb.st_mode & S_IFMT) {
-                       case S_IFDIR:
-                               if (chdir(newpath) == -1) {
-                                       printwarn(&presel);
-                                       goto nochange;
-                               }
-
-                               cdprep(lastdir, lastname, path, newpath) ? (presel = FILTER) : (watch = TRUE);
-                               goto begin;
                        case S_IFREG:
                        {
                                /* If opened as vim plugin and Enter/^M pressed, pick */