]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix only the last file path is copied to selection buffer
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 6 Dec 2019 16:54:35 +0000 (22:24 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 6 Dec 2019 16:54:35 +0000 (22:24 +0530)
src/nnn.c

index e5d1f56acbe9438f58d135f89f6ab308de1eb1bb..4eb4112a72a5886a357e1e7d04a4db9a4257de66 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -306,7 +306,7 @@ static int ndents, cur, curscroll, total_dents = ENTRY_INCR;
 static int xlines, xcols;
 static int nselected;
 static uint idle;
-static uint idletimeout, selbufpos, selbuflen;
+static uint idletimeout, selbufpos, lastappendpos, selbuflen;
 static char *bmstr;
 static char *pluginstr;
 static char *opener;
@@ -1007,6 +1007,8 @@ static void startselection(void)
                        writesel(NULL, 0);
                        selbufpos = 0;
                }
+
+               lastappendpos = 0;
        }
 }
 
@@ -4834,9 +4836,11 @@ nochange:
                        /* Write the path to selection file to avoid flush */
                        if (!(dents[cur].flags & FILE_SELECTED)) {
                                utmp = selbufpos;
+                               selbufpos = lastappendpos;
                                appendfpath(newpath, mkpath(path, dents[cur].name, newpath));
                                writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
                                spawn(copier, NULL, NULL, NULL, F_NOTRACE);
+                               lastappendpos = selbufpos;
                                selbufpos = utmp;
                        }
 
@@ -4901,6 +4905,7 @@ nochange:
 
                        /* Remember current selection buffer position */
                        utmp = selbufpos;
+                       selbufpos = lastappendpos;
 
                        for (r = selstartid; r <= selendid; ++r)
                                if (!(dents[r].flags & FILE_SELECTED)) {
@@ -4915,6 +4920,7 @@ nochange:
                                writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
                                spawn(copier, NULL, NULL, NULL, F_NOTRACE);
                                /* Restore current selection buffer position */
+                               lastappendpos = selbufpos;
                                selbufpos = utmp;
                        }
                        continue;