]> Sergey Matveev's repositories - nnn.git/commitdiff
Restrict opening 0B files.
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 4 Jun 2019 15:02:16 +0000 (20:32 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 4 Jun 2019 15:02:16 +0000 (20:32 +0530)
See #187. The behaviour has always remained so confusing. In my case a 0B file
opens in the GUI editor though I have NNN_USE_EDITOR set. We have a sensible
message in place to help users with what to do next.

README.md
src/nnn.c

index 80a517e58129dc552a81062e34b83a789359ef55..fb5631896b0e4b6d6eeaaf9073e168029c0cc127 100644 (file)
--- a/README.md
+++ b/README.md
@@ -377,7 +377,6 @@ The following indicators are used in the detail view:
 | `NNN_USE_EDITOR=1` | open text files in `$EDITOR` (`$VISUAL`, if defined; fallback vi) |
 | `NNN_NO_AUTOSELECT=1` | do not auto-select matching dir in _nav-as-you-type_ mode |
 | `NNN_RESTRICT_NAV_OPEN=1` | open files on <kbd> ↵</kbd>, not <kbd>→</kbd> or <kbd>l</kbd> |
-| `NNN_RESTRICT_0B=1` | disable 0-byte file open; see [#187](https://github.com/jarun/nnn/issues/187), use _edit_ or _open with_ |
 | `NNN_TRASH=1` | trash files to the desktop Trash [default: delete] |
 | `NNN_OPS_PROG=1` | show copy, move progress on Linux |
 
index 9af7a666414ccd9c7dfcb447999989d0d9c1979c..b2f6d5f4c30f68c93c3914aaddae3239a7a98744 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -212,7 +212,7 @@ typedef struct {
        uint copymode   : 1;  /* Set when copying files */
        uint showdetail : 1;  /* Clear to show fewer file info */
        uint ctxactive  : 1;  /* Context active or not */
-       uint reserved   : 7;
+       uint reserved   : 8;
        /* The following settings are global */
        uint curctx     : 2;  /* Current context number */
        uint dircolor   : 1;  /* Current status of dir color */
@@ -224,7 +224,6 @@ typedef struct {
        uint useeditor  : 1;  /* Use VISUAL to open text files */
        uint runplugin  : 1;  /* Choose plugin mode */
        uint runctx     : 2;  /* The context in which plugin is to be run */
-       uint restrict0b : 1;  /* Restrict 0-byte file opening */
        uint filter_re  : 1;  /* Use regex filters */
        uint wild       : 1;  /* Do not sort entries on dir load */
        uint trash      : 1;  /* Move removed files to trash */
@@ -264,7 +263,6 @@ static settings cfg = {
        0, /* useeditor */
        0, /* runplugin */
        0, /* runctx */
-       0, /* restrict0b */
        1, /* filter_re */
        0, /* wild */
        0, /* trash */
@@ -396,10 +394,9 @@ static const char * const messages[] = {
 #define NNN_USE_EDITOR 8 /* flags begin here */
 #define NNN_NO_AUTOSELECT 9
 #define NNN_RESTRICT_NAV_OPEN 10
-#define NNN_RESTRICT_0B 11
-#define NNN_TRASH 12
+#define NNN_TRASH 11
 #ifdef __linux__
-#define NNN_OPS_PROG 13
+#define NNN_OPS_PROG 12
 #endif
 
 static const char * const env_cfg[] = {
@@ -414,7 +411,6 @@ static const char * const env_cfg[] = {
        "NNN_USE_EDITOR",
        "NNN_NO_AUTOSELECT",
        "NNN_RESTRICT_NAV_OPEN",
-       "NNN_RESTRICT_0B",
        "NNN_TRASH",
 #ifdef __linux__
        "NNN_OPS_PROG",
@@ -3356,7 +3352,7 @@ nochange:
                                        continue;
                                }
 
-                               if (!sb.st_size && cfg.restrict0b) {
+                               if (!sb.st_size) {
                                        printwait("empty: use edit or open with", &presel);
                                        goto nochange;
                                }
@@ -4594,10 +4590,6 @@ int main(int argc, char *argv[])
        if (xgetenv_set(env_cfg[NNN_RESTRICT_NAV_OPEN]))
                cfg.nonavopen = 1;
 
-       /* Restrict opening of 0-byte files */
-       if (xgetenv_set(env_cfg[NNN_RESTRICT_0B]))
-               cfg.restrict0b = 1;
-
 #ifdef __linux__
        if (!xgetenv_set(env_cfg[NNN_OPS_PROG])) {
                cp[5] = cp[4];