diff --git a/src/nnn.c b/src/nnn.c index fdc6f3e5..419f0660 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -459,7 +459,7 @@ static struct timespec gtimeout; #define clearprompt() printmsg("") #define printwarn() printmsg(strerror(errno)) #define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/') -#define copycurname() if (ndents) xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1) +#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1) #define settimeout() timeout(1000) #define cleartimeout() timeout(-1) #define errexit() printerr(__LINE__) @@ -3299,7 +3299,8 @@ nochange: presel = filterentries(path); /* Save current */ - copycurname(); + if (ndents) + copycurname(); if (presel == 27) { presel = 0; @@ -3388,7 +3389,8 @@ nochange: } /* Save current */ - copycurname(); + if (ndents) + copycurname(); goto begin; case SEL_STATS: if (!ndents) @@ -3432,7 +3434,8 @@ nochange: r = handle_archive(newpath, "-x", path); break; case SEL_REDRAW: - copycurname(); + if (ndents) + copycurname(); goto begin; case SEL_RENAMEALL: r = getutil(utils[VIDIR]); @@ -3478,7 +3481,8 @@ nochange: presel = FILTER; /* Save current */ - copycurname(); + if (ndents) + copycurname(); /* Repopulate as directory content may have changed */ goto begin; @@ -3623,7 +3627,8 @@ nochange: spawn("sh", "-c", g_buf, path, F_NORMAL); - copycurname(); + if (ndents) + copycurname(); if (cfg.filtermode) presel = FILTER; goto begin; @@ -3787,7 +3792,8 @@ nochange: if (cfg.filtermode) presel = FILTER; - copycurname(); + if (ndents) + copycurname(); goto begin; } else { close(fd); @@ -3926,7 +3932,8 @@ nochange: presel = FILTER; /* Save current */ - copycurname(); + if (ndents) + copycurname(); /* Repopulate as directory content may have changed */ goto begin; @@ -4002,7 +4009,8 @@ nochange: if (xlines != LINES || xcols != COLS) { idle = 0; setdirwatch(); - copycurname(); + if (ndents) + copycurname(); goto begin; } @@ -4010,7 +4018,8 @@ nochange: if (idletimeout && idle == idletimeout) { idle = 0; spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL); - copycurname(); + if (ndents) + copycurname(); goto begin; }