]> Sergey Matveev's repositories - nnn.git/commitdiff
Avoid trying to edit a non-existing file (#477)
author0xACE <0xACE@users.noreply.github.com>
Mon, 17 Feb 2020 22:21:46 +0000 (23:21 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2020 22:21:46 +0000 (03:51 +0530)
The previous implementation was inconsistent, sometimes it would
inherit the name of the parent folder of the current directory.

Other scenarios i encountered were:
1. Yield a empty search result, and try to edit. It would seemingly
   randomly select a file or folder
2. What would happen in a root path without any files residing?

src/nnn.c

index 06c677e08aaaba20b16be0138ac478144bb96eaa..7ce569e6515620e3024f70b13c68a5a415b1a548 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5453,6 +5453,8 @@ nochange:
 
                        if (ndents)
                                mkpath(path, dents[cur].name, newpath);
+                       else if (sel == SEL_EDIT) /* Avoid trying to edit a non-existing file */
+                               goto nochange;
 
                        switch (sel) {
                        case SEL_REDRAW: