Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore sort function pointers when restoring cfg #1762

Merged
merged 2 commits into from
Nov 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
jarun marked this conversation as resolved.
Show resolved Hide resolved
} else if (r == CONTROL('T')) {
/* Cycling order: clear -> size -> time -> clear */
if (cfg.timeorder)
Expand Down Expand Up @@ -8018,6 +8018,9 @@ static bool browse(char *ipath, const char *session, int pkey)
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;
jarun marked this conversation as resolved.
Show resolved Hide resolved
namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;

cfg.curctx = r;
setdirwatch();
Expand Down
Loading