]> Sergey Matveev's repositories - nnn.git/commitdiff
vim plugin: Enter clears selection and picks cuntry
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 29 Nov 2018 14:13:53 +0000 (19:43 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 29 Nov 2018 14:13:53 +0000 (19:43 +0530)
src/nnn.c

index f59a453b47a4fbbf1a80d456b4ac86723bfca7db..f2cb9c9807b51559a33d8c1f3fed9884d04f08da 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2650,6 +2650,18 @@ nochange:
                                goto begin;
                        case S_IFREG:
                        {
+                               /* If opened as vim plugin and Enter/^M pressed, pick */
+                               if (cfg.picker && sel == SEL_GOIN) {
+                                       r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
+                                       /* NOTE: This overrides any previous selection */
+                                       copybufpos = 0;
+                                       appendfpath(newpath, r);
+                                       writecp(newpath, r - 1);
+
+                                       dentfree(dents);
+                                       return;
+                               }
+
                                /* If open file is disabled on right arrow or `l`, return */
                                if (cfg.nonavopen && sel == SEL_NAV_IN)
                                        continue;
@@ -3426,12 +3438,6 @@ nochange:
                                }
                        }
 
-                       if (cfg.picker && copybufpos == 0 && ndents) {
-                               r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
-                               appendfpath(newpath, r);
-                               writecp(newpath, r - 1);
-                       }
-
                        dentfree(dents);
                        return;
                } /* switch (sel) */