Fix #889: clear selection if plugin doesn't send data

This commit is contained in:
Arun Prakash Jana 2021-03-19 00:00:37 +05:30
parent c825a9e541
commit 5f0b3b74d0
No known key found for this signature in database
GPG Key ID: A75979F35C080412
2 changed files with 8 additions and 2 deletions

View File

@ -215,6 +215,8 @@ For convenience, we provided a helper script named `.nnn-plugin-helper` and a fu
If a context is not provided, it is asked for explicitly. To skip this and choose the current context, set the `CUR_CTX` variable in `.nnn-plugin-helper` (or in the specific plugin after sourcing `.nnn-plugin-helper`) to 1.
Usage examples can be found in the Examples section below.
If a plugin doesn't send any data back to `nnn` and there's a selection, the selection is cleared.
#### Get notified on file hover
If `NNN_FIFO` is set, `nnn` will open it and write every hovered files. This can be used in plugins and external scripts, e.g. to implement file previews.

View File

@ -4754,8 +4754,11 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
char ctx, *nextpath = NULL;
ssize_t len = read_nointr(fd, g_buf, 1);
if (len != 1)
if (len != 1) {
if (selbufpos)
clearselection();
return;
}
if (g_buf[0] == '+')
ctx = (char)(get_free_ctx() + 1);
@ -4786,7 +4789,8 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
rmlistpath();
nextpath = load_input(fd, *path);
}
} else if (selbufpos)
clearselection();
if (nextpath) {
if (ctx == 0 || ctx == cfg.curctx + 1) { /* Same context */