aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-31 21:09:40 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-31 21:09:40 +0530
commitf41e68742d82bcbfd6d541a07cdacee5417f48e7 (patch)
treeb67672cce3deb00c8b06d6fd249178699f42024e
parentdb647e7c4c0e482f9b7fb0e351abd4730d5b5cac (diff)
downloadnnn-f41e68742d82bcbfd6d541a07cdacee5417f48e7.tar.gz
Fix 2 archive handling issues
- when an archive is mounted, jump into the mount point - while archiving the hovered file, exit if the archive name is same
-rw-r--r--src/nnn.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 93ef24d..5bfa1f7 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4566,6 +4566,11 @@ nochange:
continue;
}
+ if (!sb.st_size) {
+ printwait(messages[MSG_EMPTY_FILE], &presel);
+ goto nochange;
+ }
+
if (!regexec(&archive_re, dents[cur].name, 0, NULL, 0)) {
r = get_input(messages[MSG_ARCHIVE_OPTS]);
if (r == 'l' || r == 'x') {
@@ -4575,24 +4580,31 @@ nochange:
goto begin;
}
- fd = FALSE;
if (r == 'm') {
- if (!archive_mount(dents[cur].name, path, newpath, &presel))
- fd = MSG_FAILED;
- } else if (r != 'd')
- fd = MSG_INVALID_KEY;
+ if (archive_mount(dents[cur].name,
+ path, newpath, &presel)) {
+ lastname[0] = '\0';
+
+ /* Save last working directory */
+ xstrlcpy(lastdir, path, PATH_MAX);
+
+ /* Switch to mount point */
+ xstrlcpy(path, newpath, PATH_MAX);
+
+ setdirwatch();
+ goto begin;
+ } else {
+ printwait(messages[MSG_FAILED], &presel);
+ goto nochange;
+ }
+ }
if (r != 'd') {
- fd ? printwait(messages[fd], &presel) : clearprompt();
+ printwait(messages[MSG_INVALID_KEY], &presel);
goto nochange;
}
}
- if (!sb.st_size) {
- printwait(messages[MSG_EMPTY_FILE], &presel);
- goto nochange;
- }
-
/* Invoke desktop opener as last resort */
spawn(opener, newpath, NULL, NULL, opener_flags);
continue;
@@ -5123,6 +5135,9 @@ nochange:
switch (sel) {
case SEL_ARCHIVE:
+ if (r == 'c' && strcmp(tmp, dents[cur].name) == 0)
+ goto nochange;
+
mkpath(path, tmp, newpath);
if (access(newpath, F_OK) == 0) {
fd = get_input(messages[MSG_OVERWRITE]);