aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-10 19:15:40 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-10 19:15:40 +0530
commit861d44f9348ed694d6cf2109a007b0a09f359dd9 (patch)
tree597f10592b4a5e73521ca578a144cd184cda8c1b /src/nnn.c
parentcfd4a6659623014243696812daba254dd3116e12 (diff)
downloadnnn-861d44f9348ed694d6cf2109a007b0a09f359dd9.tar.gz
Simplify cd
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 00860c3..aedc79b 100644
--- 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 */