Skip to content

Commit

Permalink
Do not end selection mode before invoking plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Aug 8, 2021
1 parent 2c32f24 commit 62a0486
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,15 +1785,16 @@ static int scanselforpath(const char *path, bool getsize)
}

/* Finish selection procedure before an operation */
static void endselection(void)
static void endselection(bool endselmode)
{
int fd;
ssize_t count;
char buf[sizeof(patterns[P_REPLACE]) + PATH_MAX + (TMP_LEN_MAX << 1)];

if (g_state.selmode)
if (endselmode && g_state.selmode)
g_state.selmode = 0;

/* The code below is only for listing mode */
if (!listpath || !selbufpos)
return;

Expand Down Expand Up @@ -5256,7 +5257,7 @@ static bool prompt_run(const char *current)

static bool handle_cmd(enum action sel, const char *current, char *newpath)
{
endselection();
endselection(TRUE);

if (sel == SEL_PROMPT)
return prompt_run(current);
Expand Down Expand Up @@ -5924,7 +5925,7 @@ static int set_sort_flags(int r)
cfg.reverse = 0;
entrycmpfn = &entrycmp;
}
endselection(); /* We are going to reload dir */
endselection(TRUE); /* We are going to reload dir */
break;
case 'c':
cfg.timeorder = 0;
Expand Down Expand Up @@ -6719,7 +6720,7 @@ static bool browse(char *ipath, const char *session, int pkey)
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();
endselection(FALSE);
/* Copy path so we can return back to earlier dir */
xstrsncpy(path, rundir, PATH_MAX);
rundir[0] = '\0';
Expand Down Expand Up @@ -7036,7 +7037,7 @@ static bool browse(char *ipath, const char *session, int pkey)
refresh = TRUE;
break;
case SEL_RENAMEMUL:
endselection();
endselection(TRUE);

if (!(getutil(utils[UTIL_BASH])
&& plugscript(utils[UTIL_NMV], F_CLI))
Expand Down Expand Up @@ -7224,7 +7225,7 @@ static bool browse(char *ipath, const char *session, int pkey)
? mkpath(path, xbasename(pselbuf), newpath)
: (newpath[0] = '\0');

endselection();
endselection(TRUE);

if (!cpmvrm_selection(sel, path)) {
presel = MSGWAIT;
Expand Down Expand Up @@ -7258,7 +7259,7 @@ static bool browse(char *ipath, const char *session, int pkey)
break;

if (sel != SEL_OPENWITH)
endselection();
endselection(TRUE);

switch (sel) {
case SEL_ARCHIVE:
Expand Down Expand Up @@ -7440,7 +7441,7 @@ static bool browse(char *ipath, const char *session, int pkey)
}

if (r != '\r') {
endselection();
endselection(FALSE);
tmp = get_kv_val(plug, NULL, r, maxplug, NNN_PLUG);
if (!tmp) {
printwait(messages[MSG_INVALID_KEY], &presel);
Expand Down

0 comments on commit 62a0486

Please sign in to comment.