Weisl/simple_renaming

Search and Select uses regex only if match case is off.

Opened this issue · 0 comments

Okxa commented

search_and_select function has an issue where the regex is only used if match case is checked, regardless of "Use Regex" checkbox.

https://github.com/Weisl/simple_renaming_panel/blob/bcdcf9fc7f26729f3f63fd126bda1f9343cd34e7/operators/search_select.py#L53-L59

Something like this should work:

if wm.renaming_useRegex == False:
    if wm.renaming_matchcase == True:
        if entityName.find(searchReplaced) >= 0:
            selectionList.append(entity)
            msg.addMessage("selected", entityName)
    else:
        if re.search(searchReplaced, entityName, re.IGNORECASE):
            selectionList.append(entity)
else:
    if re.search(searchReplaced, entityName):
        selectionList.append(entity)

It should be the correct logic, assuming the previous implementation was correct for renaming when ignoring case. (And if when searching with regex the match case option should be ignored. Atleast the Match Case checkbox is greyed out when Use Regex is checked)