Skip to content

Commit 2bc83ec

Browse files
committed
project: decrease score if .c is matched against .hh (#549)
1 parent fe6825a commit 2bc83ec

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/project.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,16 @@ Project::Entry Project::findEntry(const std::string &path, bool can_redirect,
551551
if (!best) {
552552
// Infer args from a similar path.
553553
int best_score = INT_MIN;
554+
auto [lang, header] = lookupExtension(path);
554555
for (auto &[root, folder] : root2folder)
555556
if (StringRef(path).startswith(root))
556557
for (const Entry &e : folder.entries)
557558
if (e.compdb_size) {
558559
int score = computeGuessScore(path, e.filename);
560+
// Decrease score if .c is matched against .hh
561+
auto [lang1, header1] = lookupExtension(e.filename);
562+
if (lang != lang1 && !(lang == LanguageId::C && header))
563+
score -= 30;
559564
if (score > best_score) {
560565
best_score = score;
561566
best_compdb_folder = &folder;

0 commit comments

Comments
 (0)