mirror of
https://github.com/jarun/nnn.git
synced 2025-01-22 08:46:38 +00:00
Fix #381
This commit is contained in:
parent
3c28d1f1d7
commit
950a8f6a65
28
src/nnn.c
28
src/nnn.c
|
@ -3385,7 +3385,7 @@ static bool plctrl_init(void)
|
||||||
return _SUCCESS;
|
return _SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool run_selected_plugin(char **path, const char *file, char *newpath, char *rundir, char *runfile, char **lastname, char **lastdir)
|
static bool run_selected_plugin(char **path, const char *file, char *newpath, char *rundir, char *runfile, char **lastname, char **lastdir, bool direct)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -3397,24 +3397,30 @@ static bool run_selected_plugin(char **path, const char *file, char *newpath, ch
|
||||||
|
|
||||||
if ((cfg.runctx != cfg.curctx)
|
if ((cfg.runctx != cfg.curctx)
|
||||||
/* Must be in plugin directory to select plugin */
|
/* Must be in plugin directory to select plugin */
|
||||||
|| (strcmp(*path, plugindir) != 0))
|
|| (!direct && strcmp(*path, plugindir) != 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
fd = open(g_pipepath, O_RDONLY | O_NONBLOCK);
|
fd = open(g_pipepath, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
mkpath(*path, file, newpath);
|
/* Generate absolute path to plugin */
|
||||||
|
mkpath(plugindir, file, newpath);
|
||||||
|
|
||||||
/* Copy to path so we can return back to earlier dir */
|
/* Copy to path so we can return back to earlier dir */
|
||||||
xstrlcpy(*path, rundir, PATH_MAX);
|
if (!direct) {
|
||||||
|
xstrlcpy(*path, rundir, PATH_MAX);
|
||||||
|
rundir[0] = '\0';
|
||||||
|
cfg.runplugin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (runfile && runfile[0]) {
|
if (runfile && runfile[0]) {
|
||||||
xstrlcpy(*lastname, runfile, NAME_MAX);
|
xstrlcpy(*lastname, runfile, NAME_MAX);
|
||||||
spawn(newpath, *lastname, *path, *path, F_NORMAL);
|
spawn(newpath, *lastname, *path, *path, F_NORMAL);
|
||||||
runfile[0] = '\0';
|
if (!direct)
|
||||||
|
runfile[0] = '\0';
|
||||||
} else
|
} else
|
||||||
spawn(newpath, NULL, *path, *path, F_NORMAL);
|
spawn(newpath, NULL, *path, *path, F_NORMAL);
|
||||||
rundir[0] = '\0';
|
|
||||||
cfg.runplugin = 0;
|
|
||||||
|
|
||||||
len = read(fd, g_buf, PATH_MAX);
|
len = read(fd, g_buf, PATH_MAX);
|
||||||
g_buf[len] = '\0';
|
g_buf[len] = '\0';
|
||||||
|
@ -4225,7 +4231,7 @@ nochange:
|
||||||
|
|
||||||
/* Handle plugin selection mode */
|
/* Handle plugin selection mode */
|
||||||
if (cfg.runplugin) {
|
if (cfg.runplugin) {
|
||||||
if (!run_selected_plugin(&path, dents[cur].name, newpath, rundir, runfile, &lastname, &lastdir))
|
if (!run_selected_plugin(&path, dents[cur].name, newpath, rundir, runfile, &lastname, &lastdir, FALSE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
|
@ -4966,12 +4972,10 @@ nochange:
|
||||||
spawn(newpath, (ndents ? dents[cur].name : NULL),
|
spawn(newpath, (ndents ? dents[cur].name : NULL),
|
||||||
NULL, path, F_CLI | F_CONFIRM);
|
NULL, path, F_CLI | F_CONFIRM);
|
||||||
} else {
|
} else {
|
||||||
xstrlcpy(rundir, path, PATH_MAX);
|
|
||||||
xstrlcpy(path, plugindir, PATH_MAX);
|
|
||||||
cfg.runctx = cfg.curctx;
|
cfg.runctx = cfg.curctx;
|
||||||
if (!run_selected_plugin(&path, tmp, newpath, rundir,
|
if (!run_selected_plugin(&path, tmp, newpath, NULL,
|
||||||
(ndents ? dents[cur].name : NULL),
|
(ndents ? dents[cur].name : NULL),
|
||||||
&lastname, &lastdir))
|
&lastname, &lastdir, TRUE))
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue