commit 703d34938900bf2413fabdc5f2619c922ef5e3e2
parent 9259170afd82943180b58cd0e645a54cb3a614be
Author: blissful <blissful@sunsetglow.net>
Date: Fri, 17 Nov 2023 17:25:16 -0500
restore sort function pointers when restoring cfg
Diffstat:
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -4308,6 +4308,9 @@ static void savecurctx(char *path, char *curname, int nextctx)
tmpcfg.curctx = nextctx;
cfg = tmpcfg;
+ /* Restore the global function pointers alongside the cfg. */
+ entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
+ namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
}
#ifndef NOSSN
@@ -6248,11 +6251,8 @@ static int set_sort_flags(int r)
r = 'd';
}
- if (cfg.version)
- namecmpfn = &xstrverscasecmp;
-
- if (cfg.reverse)
- entrycmpfn = &reventrycmp;
+ entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
+ namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
} else if (r == CONTROL('T')) {
/* Cycling order: clear -> size -> time -> clear */
if (cfg.timeorder)
@@ -8018,6 +8018,9 @@ nochange:
lastname = g_ctx[r].c_name;
cfg = g_ctx[r].c_cfg;
+ /* Restore the global function pointers alongside the cfg. */
+ entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
+ namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
cfg.curctx = r;
setdirwatch();