mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Simplify cd
This commit is contained in:
parent
cfd4a66596
commit
861d44f934
18
src/nnn.c
18
src/nnn.c
|
@ -5461,6 +5461,16 @@ nochange:
|
||||||
mkpath(path, dents[cur].name, newpath);
|
mkpath(path, dents[cur].name, newpath);
|
||||||
DPRINTF_S(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 */
|
/* Cannot use stale data in entry, file may be missing by now */
|
||||||
if (stat(newpath, &sb) == -1) {
|
if (stat(newpath, &sb) == -1) {
|
||||||
printwarn(&presel);
|
printwarn(&presel);
|
||||||
|
@ -5469,14 +5479,6 @@ nochange:
|
||||||
DPRINTF_U(sb.st_mode);
|
DPRINTF_U(sb.st_mode);
|
||||||
|
|
||||||
switch (sb.st_mode & S_IFMT) {
|
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:
|
case S_IFREG:
|
||||||
{
|
{
|
||||||
/* If opened as vim plugin and Enter/^M pressed, pick */
|
/* If opened as vim plugin and Enter/^M pressed, pick */
|
||||||
|
|
Loading…
Reference in a new issue