diff --git a/src/config.h b/src/config.h index b0776c3d..7835e651 100644 --- a/src/config.h +++ b/src/config.h @@ -24,7 +24,7 @@ struct Config { bool logSkippedPathsForIndex = false; // Maximum workspace search results. - int maxWorkspaceSearchResults = 200; + int maxWorkspaceSearchResults = 500; // Force a certain number of indexer threads. If less than 1 a default value // should be used. diff --git a/src/indexer.cc b/src/indexer.cc index 11c546af..6747619d 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -104,7 +104,26 @@ struct NamespaceHelper { std::string name = namespaces[i].get_spelling(); // Empty name indicates unnamed namespace, anonymous struct, anonymous // union, ... - qualifier += name.empty() ? "(anon)" : name; + if (name.size()) + qualifier += name; + else + switch (namespaces[i].get_kind()) { + case CXCursor_ClassDecl: + qualifier += "(anon class)"; + break; + case CXCursor_EnumDecl: + qualifier += "(anon enum)"; + break; + case CXCursor_StructDecl: + qualifier += "(anon struct)"; + break; + case CXCursor_UnionDecl: + qualifier += "(anon union)"; + break; + default: + qualifier += "(anon)"; + break; + } qualifier += "::"; container_cursor_to_qualified_name[namespaces[i]] = qualifier; } diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index 1122e1a8..e617ba65 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -160,13 +160,10 @@ int FuzzyEvaluate(const std::string& pattern, pfirst = pstart = false; } - // Enumerate the end position of the match in str. + // Enumerate the end position of the match in str. Each removed trailing + // character has a penulty of kGapScore. lefts = kMinScore; for (int i = 0; i < int(str.size()); i++) - // For function types, db->detailed_names may have trailing characters for - // parameters. We do not want to penalize them. - // If we use `short_name` instead of `detailed_name` for fuzzy matching, the - // penulty kGapScore can be used. lefts = std::max(lefts + kGapScore, dp[i]); return lefts; } @@ -227,27 +224,24 @@ struct WorkspaceSymbolHandler : BaseMessageHandler { } // Sort results with a fuzzy matching algorithm. - if (unsorted_results.size() < config->maxWorkspaceSearchResults) { - int longest = 0; - for (int i: result_indices) - longest = std::max(longest, int(db->short_names[i].size())); + int longest = 0; + for (int i: result_indices) + longest = std::max(longest, int(db->short_names[i].size())); - std::vector score(longest), // score for each position - dp(longest); // dp[i]: maximum value by aligning pattern to str[0..i] - std::vector> permutation(result_indices.size()); - for (int i = 0; i < int(result_indices.size()); i++) { - permutation[i] = { - FuzzyEvaluate(query, db->short_names[result_indices[i]], score, - dp), - i}; - } - std::sort(permutation.begin(), permutation.end(), - std::greater>()); - out.result.reserve(result_indices.size()); - for (int i = 0; i < int(result_indices.size()); i++) - out.result.push_back(std::move(unsorted_results[permutation[i].second])); - } else - out.result = std::move(unsorted_results); + std::vector score(longest), // score for each position + dp(longest); // dp[i]: maximum value by aligning pattern to str[0..i] + std::vector> permutation(result_indices.size()); + for (int i = 0; i < int(result_indices.size()); i++) { + permutation[i] = { + FuzzyEvaluate(query, db->short_names[result_indices[i]], score, + dp), + i}; + } + std::sort(permutation.begin(), permutation.end(), + std::greater>()); + out.result.reserve(result_indices.size()); + for (int i = 0; i < int(result_indices.size()); i++) + out.result.push_back(std::move(unsorted_results[permutation[i].second])); LOG_S(INFO) << "[querydb] Found " << out.result.size() << " results for query " << query;