-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
filter function restore on session load #1970
Conversation
src/nnn.c
Outdated
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, entrycmpfn
and namecmpfn
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
andnamecmpfn
are being set withoutsetcfg
not being called in the current code?
Okay, just tested it out and the answer is that they're not being set. To reproduce:
- Open nnn
- Switch to regex filtering
- Save session (e.g name it "regex")
- Close nnn
- Open nnn again (with string filter being default)
- Load "regex" session
- Try to search with regex, e.g
^s
and notice that there's no match even though it should matchsrc/
folder.
With the current PR, if I repeat steps 5-7 then the regex works properly.
I think the patch looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to understand how
entrycmpfn
andnamecmpfn
are being set withoutsetcfg
not being called in the current code?
Ah, wait. I didn't read carefully. entrycmpfn
and namecmpfn
are being set inside the set_sort_flags('\0');
.
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.
Me neither after looking a bit more. I've changed it back to only doing filterfn
now.
I can reproduce this by compiling with ASan: $ make CFLAGS_OPTIMIZATION='-g3 -fsanitize=address,undefined' And then switching between string and regex filtered context. Commit 0beb2b8 fixes the issue and looks good to me. I don't know about the other commit since I don't use sessions and haven't tested it. |
This comment was marked as outdated.
This comment was marked as outdated.
this should fix more crashes related to switching between contexts with different types of filters active. particularly when switching from a regex filtered context to a string filtered one.
0beb2b8
to
a9093c6
Compare
Thank you! |
loading a session or switching to a different context with a different filter mode setting (regex vs string) will not update the filter function and can lead to crashes