Просмотр исходного кода

Fixes the following workflow:

- press pick plugin key
- navigate away from the plugin directory (to ~, say)
- try to open any file, fails

When we are in run plugin mode, but detect we are in a different
context or a non-plugin directory, just cancel the runplgin mode
and continue as usual.

It also cleans up the plugin run function.
master
Arun Prakash Jana 5 лет назад
Родитель
Сommit
6693bf8f13
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: A75979F35C080412
1 измененных файлов: 26 добавлений и 22 удалений
  1. +26
    -22
      src/nnn.c

+ 26
- 22
src/nnn.c Просмотреть файл

@@ -3398,7 +3398,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, bool direct) static bool run_selected_plugin(char **path, const char *file, char *newpath, char *runfile, char **lastname, char **lastdir)
{ {
int fd; int fd;
size_t len; size_t len;
@@ -3408,10 +3408,6 @@ static bool run_selected_plugin(char **path, const char *file, char *newpath, ch
g_plinit = TRUE; g_plinit = TRUE;
} }


/* Must be in plugin directory to select plugin */
if (!direct && ((cfg.runctx != cfg.curctx) || (strcmp(*path, plugindir) != 0)))
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;
@@ -3419,18 +3415,9 @@ static bool run_selected_plugin(char **path, const char *file, char *newpath, ch
/* Generate absolute path to plugin */ /* Generate absolute path to plugin */
mkpath(plugindir, file, newpath); mkpath(plugindir, file, newpath);


/* Copy to path so we can return back to earlier dir */
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);
if (!direct)
runfile[0] = '\0';
} else } else
spawn(newpath, NULL, *path, *path, F_NORMAL); spawn(newpath, NULL, *path, *path, F_NORMAL);


@@ -4243,11 +4230,28 @@ 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, FALSE)) cfg.runplugin = 0;
continue; /* Must be in plugin dir and same context to select plugin */
if ((cfg.runctx != cfg.curctx)
|| (strcmp(path, plugindir) != 0))
; /* We are somewhere else, continue as usual */
else {
/* Copy path so we can return back to earlier dir */
xstrlcpy(path, rundir, PATH_MAX);
rundir[0] = '\0';

if (!run_selected_plugin(&path, dents[cur].name,
newpath, runfile, &lastname,
&lastdir)) {
DPRINTF_S("plugin failed!");
}


setdirwatch(); if (runfile[0])
goto begin; runfile[0] = '\0';

setdirwatch();
goto begin;
}
} }


/* If NNN_USE_EDITOR is set, open text in EDITOR */ /* If NNN_USE_EDITOR is set, open text in EDITOR */
@@ -4993,11 +4997,11 @@ nochange:


spawn(newpath, tmp, NULL, path, F_CLI | F_CONFIRM); spawn(newpath, tmp, NULL, path, F_CLI | F_CONFIRM);
} else { } else {
if (!run_selected_plugin(&path, tmp, newpath, NULL, if (!run_selected_plugin(&path, tmp, newpath,
(ndents ? dents[cur].name : NULL), (ndents ? dents[cur].name : NULL),
&lastname, &lastdir, TRUE)) { &lastname, &lastdir)) {
if (cfg.filtermode) printwait(messages[OPERATION_FAILED],
presel = FILTER; &presel);
goto nochange; goto nochange;
} }
} }


||||||
x
 
000:0
Загрузка…
Отмена
Сохранить