Skip to content

Commit

Permalink
project: decrease score if .c is matched against .hh (MaskRay#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 28, 2019
1 parent ed64919 commit e2284a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,16 @@ Project::Entry Project::findEntry(const std::string &path, bool can_redirect,
if (!best) {
// Infer args from a similar path.
int best_score = INT_MIN;
auto [lang, header] = lookupExtension(path);
for (auto &[root, folder] : root2folder)
if (StringRef(path).startswith(root))
for (const Entry &e : folder.entries)
if (e.compdb_size) {
int score = computeGuessScore(path, e.filename);
// Decrease score if .c is matched against .hh
auto [lang1, header1] = lookupExtension(e.filename);
if (lang != lang1 && !(lang == LanguageId::C && header))
score -= 30;
if (score > best_score) {
best_score = score;
best_compdb_folder = &folder;
Expand Down

0 comments on commit e2284a3

Please sign in to comment.