From 6c87a4656cee232518d9029c4ebb168c46353f9b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 22 Dec 2019 10:06:34 -0800 Subject: [PATCH] project: decrease score if .c is matched against .hh (#549) --- src/project.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/project.cc b/src/project.cc index e22e523c..120a958f 100644 --- a/src/project.cc +++ b/src/project.cc @@ -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;