]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix https://github.com/mcchrish/nnn.vim/issues/39
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 Feb 2019 04:28:13 +0000 (09:58 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 Feb 2019 04:28:13 +0000 (09:58 +0530)
If nnn is started in the picker mode, do NOT use libreadline.
Fallback to the stock mechanism to show the command prompt.

src/nnn.c

index 02c53fa082518a4438a0e93d30410c36088150a3..6ca2e5665c966c2e8c82cda1bfb0f7a968dd6f15 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3888,27 +3888,35 @@ nochange:
                                }
                                break;
                        default: /* SEL_RUNCMD */
-                               exitcurses();
+                               if (cfg.picker)
+                                       tmp = xreadline(NULL, "> ");
+                               else {
+                                       /* Use libreadline */
+                                       exitcurses();
+
+                                       /* Switch to current path for readline(3) */
+                                       if (chdir(path) == -1) {
+                                               printwarn();
+                                               goto nochange;
+                                       }
 
-                               /* Switch to current path for readline(3) */
-                               if (chdir(path) == -1) {
-                                       printwarn();
-                                       goto nochange;
-                               }
+                                       tmp = readline("nnn> ");
 
-                               tmp = readline("nnn> ");
+                                       if (chdir(ipath) == -1) {
+                                               printwarn();
+                                               goto nochange;
+                                       }
 
-                               if (chdir(ipath) == -1) {
-                                       printwarn();
-                                       goto nochange;
+                                       refresh();
                                }
 
-                               refresh();
-
                                if (tmp && tmp[0]) {
                                        spawn(shell, "-c", tmp, path, F_NORMAL | F_SIGINT);
-                                       add_history(tmp);
-                                       free(tmp);
+                                       if (!cfg.picker) {
+                                               /* readline finishing touches */
+                                               add_history(tmp);
+                                               free(tmp);
+                                       }
                                }
                        }