Skip to content

Commit

Permalink
Fix reference references bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Mar 8, 2024
1 parent 45e7272 commit 987793e
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ use tower_lsp::lsp_types::{Location, Position, Url};
use crate::vault::{Reference, Vault};

pub fn references(vault: &Vault, cursor_position: Position, path: &Path) -> Option<Vec<Location>> {

let references: Vec<(&Path, &Reference)> = vault
.select_referenceable_at_position(path, cursor_position)
.and_then(|referenceable| vault.select_references_for_referenceable(&referenceable))
.or(vault
.select_reference_at_position(path, cursor_position)
.map(|reference| {
let referenceables = vault.select_referenceables_for_reference(reference, path);
let references = referenceables
.into_iter()
.filter_map(|referenceable| {
vault.select_references_for_referenceable(&referenceable)
}) // drop the Nones on the options
.flatten()
.collect_vec();
.select_reference_at_position(path, cursor_position)
.map(|reference| {
let referenceables = vault.select_referenceables_for_reference(reference, path);
let references = referenceables
.into_iter()
.filter_map(|referenceable| {
vault.select_references_for_referenceable(&referenceable)
}) // drop the Nones on the options
.flatten()
.collect_vec();

references
}))?;
references
})
.or(vault
.select_referenceable_at_position(path, cursor_position)
.and_then(|referenceable| vault.select_references_for_referenceable(&referenceable))
)?;

Some(
references
Expand Down

0 comments on commit 987793e

Please sign in to comment.