]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #1098: clear selmode on last deselect
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 6 Jul 2021 17:55:49 +0000 (23:25 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 6 Jul 2021 17:55:49 +0000 (23:25 +0530)
src/nnn.c

index c4bced5685b1c2d8d8c559faaa34b7d47c920c02..a3f591127fdf38f4006ed80f3fc174456c60c4d3 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1498,6 +1498,14 @@ static void startselection(void)
        }
 }
 
+static void clearselection(void)
+{
+       nselected = 0;
+       selbufpos = 0;
+       g_state.selmode = 0;
+       writesel(NULL, 0);
+}
+
 static size_t appendslash(char *path)
 {
 
@@ -1533,10 +1541,9 @@ static void invertselbuf(char *path, bool toggle)
                if (len > 1)
                        --len;
                path[len] = '\0';
+       }
 
-               nselected ? writesel(pselbuf, selbufpos - 1) : writesel(NULL, 0);
-       } else
-               writesel(NULL, 0);
+       nselected ? writesel(pselbuf, selbufpos - 1) : clearselection();
 }
 
 static void addtoselbuf(char *path, int startid, int endid)
@@ -1626,14 +1633,6 @@ static void endselection(void)
        writesel(pselbuf, selbufpos - 1);
 }
 
-static void clearselection(void)
-{
-       nselected = 0;
-       selbufpos = 0;
-       g_state.selmode = 0;
-       writesel(NULL, 0);
-}
-
 /* Returns: 1 - success, 0 - none selected, -1 - other failure */
 static int editselection(void)
 {
@@ -6858,9 +6857,6 @@ nochange:
                        if (cfg.x11)
                                plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE);
 #endif
-
-                       if (!nselected)
-                               unlink(selpath);
 #ifndef NOMOUSE
                        if (rightclicksel)
                                rightclicksel = 0;