mirror of
https://github.com/jarun/nnn.git
synced 2025-01-09 17:39:38 +00:00
Fix NULL file name handling
This commit is contained in:
parent
900513710f
commit
a62dbf093a
|
@ -4163,7 +4163,7 @@ static void savecurctx(char *path, char *curname, int nextctx)
|
||||||
context *ctxr = &g_ctx[nextctx];
|
context *ctxr = &g_ctx[nextctx];
|
||||||
|
|
||||||
/* Save current context */
|
/* Save current context */
|
||||||
if (ndents)
|
if (curname)
|
||||||
xstrsncpy(g_ctx[tmpcfg.curctx].c_name, curname, NAME_MAX + 1);
|
xstrsncpy(g_ctx[tmpcfg.curctx].c_name, curname, NAME_MAX + 1);
|
||||||
else
|
else
|
||||||
g_ctx[tmpcfg.curctx].c_name[0] = '\0';
|
g_ctx[tmpcfg.curctx].c_name[0] = '\0';
|
||||||
|
@ -4345,7 +4345,8 @@ static void set_smart_ctx(int ctx, char *nextpath, char **path, char **lastname,
|
||||||
--ctx;
|
--ctx;
|
||||||
/* Deactivate the new context and build from scratch */
|
/* Deactivate the new context and build from scratch */
|
||||||
g_ctx[ctx].c_cfg.ctxactive = 0;
|
g_ctx[ctx].c_cfg.ctxactive = 0;
|
||||||
savecurctx(nextpath, pdents[cur].name, ctx);
|
DPRINTF_S(nextpath);
|
||||||
|
savecurctx(nextpath, ndents ? pdents[cur].name : NULL, ctx);
|
||||||
*path = g_ctx[ctx].c_path;
|
*path = g_ctx[ctx].c_path;
|
||||||
*lastdir = g_ctx[ctx].c_last;
|
*lastdir = g_ctx[ctx].c_last;
|
||||||
*lastname = g_ctx[ctx].c_name;
|
*lastname = g_ctx[ctx].c_name;
|
||||||
|
@ -6589,7 +6590,7 @@ nochange:
|
||||||
if (r >= CTX_MAX)
|
if (r >= CTX_MAX)
|
||||||
sel = SEL_BACK;
|
sel = SEL_BACK;
|
||||||
else if (r >= 0 && r != cfg.curctx) {
|
else if (r >= 0 && r != cfg.curctx) {
|
||||||
savecurctx(path, pdents[cur].name, r);
|
savecurctx(path, ndents ? pdents[cur].name : NULL, r);
|
||||||
|
|
||||||
/* Reset the pointers */
|
/* Reset the pointers */
|
||||||
path = g_ctx[r].c_path;
|
path = g_ctx[r].c_path;
|
||||||
|
@ -6970,7 +6971,7 @@ nochange:
|
||||||
r = handle_context_switch(sel);
|
r = handle_context_switch(sel);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
continue;
|
continue;
|
||||||
savecurctx(path, pdents[cur].name, r);
|
savecurctx(path, ndents ? pdents[cur].name : NULL, r);
|
||||||
|
|
||||||
/* Reset the pointers */
|
/* Reset the pointers */
|
||||||
path = g_ctx[r].c_path;
|
path = g_ctx[r].c_path;
|
||||||
|
|
Loading…
Reference in a new issue