]> Sergey Matveev's repositories - nnn.git/commitdiff
Handle plugin selection early
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 1 Nov 2021 07:24:47 +0000 (12:54 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 1 Nov 2021 07:24:47 +0000 (12:54 +0530)
src/nnn.c

index 97177537834c7b4c90488924d064d8271db03e59..020cba43e6adc2acb858c79f6b6ada11bd7451f2 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6896,6 +6896,36 @@ nochange:
                                printwait(messages[MSG_UNSUPPORTED], &presel);
                                goto nochange;
                         }
+
+                       /* Handle plugin selection mode */
+                       if (g_state.runplugin) {
+                               g_state.runplugin = 0;
+                               /* Must be in plugin dir and same context to select plugin */
+                               if ((g_state.runctx == cfg.curctx) && !strcmp(path, plgpath)) {
+                                       endselection(FALSE);
+                                       /* Copy path so we can return back to earlier dir */
+                                       xstrsncpy(path, rundir, PATH_MAX);
+                                       rundir[0] = '\0';
+                                       clearfilter();
+
+                                       if (chdir(path) == -1
+                                           || !run_plugin(&path, pent->name,
+                                                                   runfile, &lastname, &lastdir)) {
+                                               DPRINTF_S("plugin failed!");
+                                       }
+
+                                       if (g_state.picked)
+                                               return EXIT_SUCCESS;
+
+                                       if (runfile[0]) {
+                                               xstrsncpy(lastname, runfile, NAME_MAX + 1);
+                                               runfile[0] = '\0';
+                                       }
+                                       setdirwatch();
+                                       goto begin;
+                               }
+                       }
+
 #ifndef NOFIFO
                        if (g_state.fifomode && (sel == SEL_OPEN)) {
                                send_to_explorer(&presel); /* Write selection to explorer fifo */
@@ -6936,35 +6966,6 @@ nochange:
                                        goto nochange;
                        }
 
-                       /* Handle plugin selection mode */
-                       if (g_state.runplugin) {
-                               g_state.runplugin = 0;
-                               /* Must be in plugin dir and same context to select plugin */
-                               if ((g_state.runctx == cfg.curctx) && !strcmp(path, plgpath)) {
-                                       endselection(FALSE);
-                                       /* Copy path so we can return back to earlier dir */
-                                       xstrsncpy(path, rundir, PATH_MAX);
-                                       rundir[0] = '\0';
-                                       clearfilter();
-
-                                       if (chdir(path) == -1
-                                           || !run_plugin(&path, pent->name,
-                                                                   runfile, &lastname, &lastdir)) {
-                                               DPRINTF_S("plugin failed!");
-                                       }
-
-                                       if (g_state.picked)
-                                               return EXIT_SUCCESS;
-
-                                       if (runfile[0]) {
-                                               xstrsncpy(lastname, runfile, NAME_MAX + 1);
-                                               runfile[0] = '\0';
-                                       }
-                                       setdirwatch();
-                                       goto begin;
-                               }
-                       }
-
                        if (!sb.st_size) {
                                printwait(messages[MSG_EMPTY_FILE], &presel);
                                goto nochange;