commit 5f0b3b74d05dd4680eb81baf98d89f174bb55bbb
parent c825a9e5413b2da758fc868d81e25bf62af35cc3
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Fri, 19 Mar 2021 00:00:37 +0530
Fix #889: clear selection if plugin doesn't send data
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/plugins/README.md b/plugins/README.md
@@ -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.
diff --git a/src/nnn.c b/src/nnn.c
@@ -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 */