Skip to content

Commit

Permalink
Fix problem with getNumMatches() ?
Browse files Browse the repository at this point in the history
  • Loading branch information
riverwanderer committed Oct 2, 2023
1 parent 4bdbca6 commit a2acbda
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vassal-app/src/main/java/VASSAL/configure/ConfigureTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -2186,9 +2186,12 @@ public void actionPerformed(ActionEvent e) {
regexPattern = setupRegexSearch(searchParameters.getSearchString());
regexError = regexPattern == null;
}
else {
regexPattern = null;
}
if (!regexError) {
// Compute & display hit count
final int matches = getNumMatches(searchParameters.getSearchString());
final int matches = getNumMatches(searchParameters.getSearchString(), regexPattern);
chat(matches + " " + Resources.getString("Editor.search_count") + noHTML(searchParameters.getSearchString()));
}
}
Expand Down Expand Up @@ -2329,10 +2332,9 @@ private DefaultMutableTreeNode findNode(String searchString) {
/**
* @return how many total nodes match the search string
*/
private int getNumMatches(String searchString) {
private int getNumMatches(String searchString, Pattern regexP) {
final List<DefaultMutableTreeNode> searchNodes = configureTree.getSearchNodes((DefaultMutableTreeNode)configureTree.getModel().getRoot());
// FIXME: should regex be passed here too ?
return (int) searchNodes.stream().filter(node -> checkNode(node, searchString, regexPattern)).count();
return (int) searchNodes.stream().filter(node -> checkNode(node, searchString, regexP)).count();
}


Expand Down

0 comments on commit a2acbda

Please sign in to comment.