-
Notifications
You must be signed in to change notification settings - Fork 7
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
Search variables using multiple words #168
base: master
Are you sure you want to change the base?
Conversation
This makes is possible to search using multiple words in the vars menu. When you do that you will find all variables that contain all of the specified words in any order. Examples: If you search for "weap rifle" you will find: - riflefragweap1 - riflefragweap2 - weapidxrifle If you search for "plasma 1" you will find all variables that modify plasma 1.
This is the only bug I have found so far: Search for "s s" and you will see that some results will have too many 's'. Similar thing also happens with 'y'. This is probably because 's' and 'y' are used for formatting and then it finds them in the format codes the next time it replaces text. |
I like the idea |
config/menus/vars.cfg
Outdated
hilvar = (stringreplace $curvar $variable_search_text (format "^fs^fy%1^fS" $variable_search_text)) | ||
hilvar = $curvar | ||
looplist variable_search_word $variable_search_text [ | ||
hilvar = (stringreplace $hilvar $variable_search_word (format "^fs^fy%1^fS" $variable_search_word)) |
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.
please add a comment that states exactly what this line does, it is not obvious
static char *laststr = NULL; | ||
if(ids[1].empty() || !laststr || strcmp(str, laststr)) | ||
{ | ||
ids[1].setsize(0); | ||
loopv(ids[0]) if(rigcasestr(ids[0][i]->name, str)) ids[1].add(ids[0][i]); | ||
loopv(ids[0]) |
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.
please do not use loop macros, instead use for (int i = 0; i < ids[0].length(); i++)
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 didn't add that loop macro. I think getting rid of the loop macros is a separate issue for another PR.
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 general we usually just remove them from code we rework/work at. It doesn't hurt anybody
This command helps with the multi word var search highlighting.
The bug I mentioned about too many 's' is fixed by this last commit d315585 |
This makes is possible to search using multiple words in the vars menu.
When you do that you will find all variables that contain all of the
specified words in any order.
Examples:
If you search for "weap rifle" you will find:
If you search for "plasma 1" you will find all variables that modify
plasma 1.