Skip to content

Commit ee55fe4

Browse files
committed
Give priority to non-section entries
1 parent 8450979 commit ee55fe4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crates/ark/src/lsp/indexer.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,17 @@ fn insert(path: &Path, entry: IndexEntry) -> anyhow::Result<()> {
126126

127127
let index = index.entry(path.to_string()).or_default();
128128

129-
// Retain the first occurrence in the index. In the future we'll track every occurrences and
130-
// their scopes but for now we only track the first definition of an object (in a way, its
129+
// We generally retain only the first occurrence in the index. In the
130+
// future we'll track every occurrences and their scopes but for now we
131+
// only track the first definition of an object (in a way, its
131132
// declaration).
132-
if !index.contains_key(&entry.key) {
133+
if let Some(existing_entry) = index.get(&entry.key) {
134+
// Give priority to non-section entries.
135+
if matches!(existing_entry.data, IndexEntryData::Section { .. }) {
136+
index.insert(entry.key.clone(), entry);
137+
}
138+
// Else, ignore.
139+
} else {
133140
index.insert(entry.key.clone(), entry);
134141
}
135142

0 commit comments

Comments
 (0)