Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion config/menus/vars.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ menu_variables = [
q = (+ $variable_index $i)
if (< $q $numvars) [
curvar = (getvarinfo $q $variable_types $variable_no_types $variable_flags $variable_no_flags $variable_search_text)
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))
Copy link
Copy Markdown
Contributor

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

]
ui_list [ ui_radiobutton $hilvar variable_number $q ]
] [ ui_strut 1 ]
]
Expand Down
15 changes: 14 additions & 1 deletion src/engine/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3579,11 +3579,24 @@ void getvarinfo(int n, int types, int notypes, int flags, int noflags, char *str
}
if(str && *str)
{
std::vector<std::string> words;
explodelist(str, words);
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])
Copy link
Copy Markdown
Contributor

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++)

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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

{
bool matches = true;
for (const std::string &word : words)
{
if(!rigcasestr(ids[0][i]->name, word.c_str()))
{
matches = false;
}
}
if(matches) ids[1].add(ids[0][i]);
}
if(laststr) DELETEA(laststr);
laststr = newstring(str);
}
Expand Down