]> Sergey Matveev's repositories - nnn.git/commitdiff
Remove redundant search when entering directory
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 8 Apr 2017 05:44:51 +0000 (11:14 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 8 Apr 2017 05:44:51 +0000 (11:14 +0530)
nnn.c

diff --git a/nnn.c b/nnn.c
index e12e1471fa32ea51ba3e1ccd56820e655254aeaa..fedd65bfb0e74f2eb12dda1a8b89542db8126d96 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -1065,13 +1065,18 @@ browse(char *ipath, char *ifilter)
        struct stat sb;
        regex_t re;
        int r, fd;
+       enum action sel = SEL_RUNARG + 1;
 
        xstrlcpy(path, ipath, sizeof(path));
        xstrlcpy(fltr, ifilter, sizeof(fltr));
        oldpath[0] = '\0';
        newpath[0] = '\0';
 begin:
-       r = populate(path, oldpath, fltr);
+
+       if (sel == SEL_GOIN && S_ISDIR(sb.st_mode))
+               r = populate(path, NULL, fltr);
+       else
+               r = populate(path, oldpath, fltr);
        if (r == -1) {
                printwarn();
                goto nochange;
@@ -1080,7 +1085,8 @@ begin:
        for (;;) {
                redraw(path);
 nochange:
-               switch (nextsel(&run, &env)) {
+               sel = nextsel(&run, &env);
+               switch (sel) {
                case SEL_QUIT:
                        dentfree(dents);
                        return;