]> Sergey Matveev's repositories - nnn.git/commitdiff
^L at empty prompt shows last filter
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Jan 2020 22:06:08 +0000 (03:36 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Jan 2020 22:06:08 +0000 (03:36 +0530)
src/nnn.c

index 5029c807393d74e61e9da1083ac5fd252f9b4c0d..81e6929011bc6a29090ff814da8cab5707d52ef4 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2119,10 +2119,25 @@ static int filterentries(char *path, char *lastname)
                                goto end;
                        }
 
-                       if (*ch == CONTROL('L') && wln[1]) {
-                               ln[REGEX_MAX - 1] = ln[1];
-                               wln[1] = '\0';
-                               len = 1;
+                       if (*ch == CONTROL('L')) {
+                               if (wln[1]) {
+                                       ln[REGEX_MAX - 1] = ln[1];
+                                       wln[1] = '\0';
+                                       len = 1;
+                               } else if (ln[REGEX_MAX - 1]) { /* Show the previous filter */
+                                       ln[1] = ln[REGEX_MAX - 1];
+                                       ln[REGEX_MAX - 1] = '\0';
+                                       len = mbstowcs(wln, ln, REGEX_MAX);
+                                       /* Go to the top, we don't know if the
+                                          hovered file will match the filter */
+                                       cur = 0;
+
+                                       if (matches(pln) != -1)
+                                               redraw(path);
+
+                                       showfilter(ln);
+                                       continue;
+                               }
                        } else
                                wln[--len] = '\0';
 
@@ -2138,21 +2153,6 @@ static int filterentries(char *path, char *lastname)
                case KEY_MOUSE: // fallthrough
                case 27: /* Exit filter mode on Escape */
                        goto end;
-               case KEY_UP: /* On the first Up, apply previous filter */
-                       if (len == 1 && ln[REGEX_MAX - 1]) {
-                               ln[1] = ln[REGEX_MAX - 1];
-                               ln[REGEX_MAX - 1] = '\0';
-                               len = mbstowcs(wln, ln, REGEX_MAX);
-                               /* Go to the top, we don't know if the
-                                  hovered file will match the filter */
-                               cur = 0;
-
-                               if (matches(pln) != -1)
-                                       redraw(path);
-
-                               showfilter(ln);
-                               continue;
-                       }
                }
 
                if (r == OK) {