diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2019-10-11 23:19:25 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2019-10-11 23:19:25 +0530 |
commit | d1d491c102f5da1bf6a2c8c21fa71530e74f90d3 (patch) | |
tree | 191129298cc38228a3313f850656604722c84548 /src | |
parent | c99a47d68898700160bec9f9ef3547cc39b49ecf (diff) | |
download | nnn-d1d491c102f5da1bf6a2c8c21fa71530e74f90d3.tar.gz |
Fix #350: cd on quit if NNN_TMPFILE is set
Diffstat (limited to 'src')
-rw-r--r-- | src/nnn.c | 68 |
1 files changed, 35 insertions, 33 deletions
@@ -4603,9 +4603,42 @@ nochange: } if (!(r == CTX_MAX || r == '\r')) - break; + break; // fallthrough + case SEL_QUITCTX: + if (sel == SEL_QUITCTX) { + fd = cfg.curctx; /* fd used as tmp var */ + for (r = (fd + 1) & ~CTX_MAX; + (r != fd) && !g_ctx[r].c_cfg.ctxactive; + r = ((r + 1) & ~CTX_MAX)) { + }; + + if (r != fd) { + bool selmode = cfg.selmode ? TRUE : FALSE; + + g_ctx[fd].c_cfg.ctxactive = 0; + + /* Switch to next active context */ + path = g_ctx[r].c_path; + lastdir = g_ctx[r].c_last; + lastname = g_ctx[r].c_name; + + /* Switch light/detail mode */ + if (cfg.showdetail != g_ctx[r].c_cfg.showdetail) + /* Set the reverse */ + printptr = cfg.showdetail ? + &printent : &printent_long; + + cfg = g_ctx[r].c_cfg; + + /* Continue selection mode */ + cfg.selmode = selmode; + cfg.curctx = r; + setdirwatch(); + goto begin; + } + } - if (sel == SEL_QUITCD) { + if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) { /* In vim picker mode, clear selection and exit */ if (cfg.picker) { /* Picker mode: reset buffer or clear file */ @@ -4617,37 +4650,6 @@ nochange: } } return; - case SEL_QUITCTX: - fd = cfg.curctx; /* fd used as tmp var */ - for (r = (fd + 1) & ~CTX_MAX; - (r != fd) && !g_ctx[r].c_cfg.ctxactive; - r = ((r + 1) & ~CTX_MAX)) { - }; - - if (r != fd) { - bool selmode = cfg.selmode ? TRUE : FALSE; - - g_ctx[fd].c_cfg.ctxactive = 0; - - /* Switch to next active context */ - path = g_ctx[r].c_path; - lastdir = g_ctx[r].c_last; - lastname = g_ctx[r].c_name; - - /* Switch light/detail mode */ - if (cfg.showdetail != g_ctx[r].c_cfg.showdetail) - /* Set the reverse */ - printptr = cfg.showdetail ? &printent : &printent_long; - - cfg = g_ctx[r].c_cfg; - - /* Continue selection mode */ - cfg.selmode = selmode; - cfg.curctx = r; - setdirwatch(); - goto begin; - } - return; default: if (xlines != LINES || xcols != COLS) { idle = 0; |