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

filter function restore on session load #1970

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4385,6 +4385,7 @@ static void setcfg(settings newcfg)
/* Synchronize the global function pointers to match the new cfg. */
entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
filterfn = cfg.regex ? &visible_re : &visible_str;
}

static void savecurctx(char *path, char *curname, int nextctx)
Expand Down Expand Up @@ -4542,6 +4543,7 @@ static bool load_session(const char *sname, char **path, char **lastdir, char **
*path = g_ctx[cfg.curctx].c_path;
*lastdir = g_ctx[cfg.curctx].c_last;
*lastname = g_ctx[cfg.curctx].c_name;
setcfg(cfg);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are the other 2 working without calling setcfg()? Is savecurtx() being called in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other 2 contexts? savecurtx() should be called on any context switch, I think. I don't really like calling setcfg here, because it doesn't change the cfg assignment and set_sort_flags() already sets the other two function pointers. the important point is that the filter function pointer is set for the current context after the session is loaded. i think one of the individual commits has some more information on that

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, entrycmpfn and namecmpfn.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not clear, I wanted to understand how entrycmpfn and namecmpfn are being set without setcfg not being called in the current code?

set_sort_flags('\0'); /* Set correct sort options */
xstrsncpy(curssn, sname ? sname : "@", NAME_MAX);
status = TRUE;
Expand Down
Loading