From 73f7b911b2d4fb80d81ac61eafd5fdac5435b445 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 13 Apr 2024 18:24:42 -0700 Subject: [PATCH] Fix table not becoming first responder when one variable is found --- Bit Slicer/ZGDocumentSearchController.m | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Bit Slicer/ZGDocumentSearchController.m b/Bit Slicer/ZGDocumentSearchController.m index 30fdac71..de85249a 100644 --- a/Bit Slicer/ZGDocumentSearchController.m +++ b/Bit Slicer/ZGDocumentSearchController.m @@ -1328,6 +1328,7 @@ - (void)searchVariablesWithString:(NSString *)searchStringValue dataType:(ZGVari [[NSProcessInfo processInfo] endActivity:searchDataActivity]; } + BOOL onlySingleNewNotableVariableFound; if (!self->_searchProgress.shouldCancelSearch) { ZGDeliverUserNotification(ZGLocalizableSearchDocumentString(@"searchFinishedNotificationTitle"), windowController.currentProcess.name, [self numberOfVariablesFoundDescriptionFromProgress:self->_searchProgress], nil); @@ -1340,6 +1341,9 @@ - (void)searchVariablesWithString:(NSString *)searchStringValue dataType:(ZGVari self->_searchResults = self->_temporarySearchResults; self->_documentData.variables = notSearchedVariables; + + onlySingleNewNotableVariableFound = (self->_searchResults.count == 1 && self->_searchResults.resultType == ZGSearchResultTypeDirect); + [self fetchVariablesFromResultsAndFinishedSearch:YES]; [windowController.variablesTableView reloadData]; @@ -1352,12 +1356,16 @@ - (void)searchVariablesWithString:(NSString *)searchStringValue dataType:(ZGVari // New search didn't return any new results, so let's show old variables again self->_documentData.variables = oldVariables; [windowController.variablesTableView reloadData]; + + onlySingleNewNotableVariableFound = NO; } } else { self->_documentData.variables = oldVariables; [windowController.variablesTableView reloadData]; + + onlySingleNewNotableVariableFound = NO; } dispatch_async(self->_machBinaryAnnotationInfoQueue, ^{ @@ -1375,18 +1383,10 @@ - (void)searchVariablesWithString:(NSString *)searchStringValue dataType:(ZGVari // Make the table first responder if we come back from a search and only one variable was found. Hopefully the user found what they were looking for. // But don't do this if the user is searching for indirect variables - if (!pointerAddressSearch && !self->_searchProgress.shouldCancelSearch && self->_documentData.variables.count <= MAX_NUMBER_OF_VARIABLES_TO_FETCH) + if (onlySingleNewNotableVariableFound) { - NSArray *filteredVariables = [self->_documentData.variables zgFilterUsingBlock:(zg_array_filter_t)^(ZGVariable *variable) { - return variable.enabled; - }]; - - // Make sure single variable is not indirect variable from a value search - if (filteredVariables.count == 1 && !filteredVariables[0].usesDynamicPointerAddress) - { - [windowController.window makeFirstResponder:windowController.variablesTableView]; - shouldMakeSearchFieldFirstResponder = NO; - } + [windowController.window makeFirstResponder:windowController.variablesTableView]; + shouldMakeSearchFieldFirstResponder = NO; } [self resumeFromTaskAndMakeSearchFieldFirstResponder:shouldMakeSearchFieldFirstResponder];