Skip to content

Commit 88a1da9

Browse files
committed
project: override the compdb entry with .ccls if compile_commands.json is not used
Note: `exact_match` should be false if the entry is an synthetic one, instead of an explicit entry in compile_commands.json
1 parent f19c584 commit 88a1da9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/project.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,10 @@ Project::Entry Project::findEntry(const std::string &path, bool can_redirect,
522522
auto it = folder.path2entry_index.find(path);
523523
if (it != folder.path2entry_index.end()) {
524524
Project::Entry &entry = folder.entries[it->second];
525-
exact_match = entry.filename == path;
526-
if ((match = exact_match || can_redirect) || entry.compdb_size) {
527-
// best->compdb_size is >0 for a compdb entry, 0 for a .ccls entry.
525+
// best->compdb_size is >0 for an explicit compile_commands.json
526+
// entry, 0 for an implicit entry.
527+
exact_match = entry.compdb_size > 0 && entry.filename == path;
528+
if ((match = exact_match || can_redirect) && entry.compdb_size) {
528529
best_compdb_folder = &folder;
529530
best = &entry;
530531
}

0 commit comments

Comments
 (0)