aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-13 00:36:30 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-13 00:36:30 +0530
commit5a46b8fb25b0f4f073920ca2b82ad96828475a99 (patch)
treeac96872e45272940a6477e2153e1140a57c52a5e /src
parente7236662560ecc687b5349b825a438aed30f5874 (diff)
downloadnnn-5a46b8fb25b0f4f073920ca2b82ad96828475a99.tar.gz
Sync file paths correctly for clipboard copy
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 2ad8f27..6fdae5a 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4864,26 +4864,34 @@ nochange:
if (rangesel)
rangesel = FALSE;
- /* Write the path to selection file to avoid flush */
- if (!(dents[cur].flags & FILE_SELECTED)) {
+ /* Toggle selection status */
+ dents[cur].flags ^= FILE_SELECTED;
+
+ if (dents[cur].flags & FILE_SELECTED) {
+ ++nselected;
utmp = selbufpos;
selbufpos = lastappendpos;
appendfpath(newpath, mkpath(path, dents[cur].name, newpath));
writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
- if (cfg.x11)
- plugscript(utils[UTIL_CBCP], newpath, F_NOWAIT | F_NOTRACE);
lastappendpos = selbufpos;
selbufpos = utmp;
+ } else {
+ --nselected;
+ if (nselected) {
+ utmp = selbufpos;
+ updateselbuf(path, newpath);
+ writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
+ lastappendpos = selbufpos;
+ selbufpos = utmp;
+ } else
+ writesel(NULL, 0);
}
- /* Toggle selection status */
- dents[cur].flags ^= FILE_SELECTED;
- (dents[cur].flags & FILE_SELECTED) ? ++nselected : --nselected;
+ if (cfg.x11)
+ plugscript(utils[UTIL_CBCP], newpath, F_NOWAIT | F_NOTRACE);
- if (!nselected) {
- writesel(NULL, 0);
+ if (!nselected)
unlink(g_selpath);
- }
/* move cursor to the next entry if this is not the last entry */
if (!cfg.picker && cur != ndents - 1)