Skip to content

Commit

Permalink
fix: show multiple paths if indexNote?
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jul 20, 2021
1 parent 5cd032c commit e302a97
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,32 +254,13 @@ export default class BreadcrumbsPlugin extends Plugin {
}

const from = currFile.basename;
const paths = graphlib.alg.dijkstra(g, from);
const indexNotes: string[] = [this.settings.indexNote].flat();

let allTrails: string[][] = [];
let allTrails: string[][] = this.bfsAllPaths(g, from);

// No index note chosen
if (indexNotes[0] === "") {
allTrails = this.bfsAllPaths(g, from);
} else {
indexNotes.forEach((index) => {
let step = index;

if (paths[step].distance !== Infinity) {
const breadcrumbs: string[] = [];
// Walk it until arriving at `from`
while (paths[step].distance !== 0) {
breadcrumbs.push(step);
step = paths[step].predecessor;
}
// if (breadcrumbs.length > 0) {
// // Add the last step
// breadcrumbs.push(from);
// }
allTrails.push(breadcrumbs);
}
});
if (indexNotes[0] !== "" && allTrails[0].length > 0) {
allTrails = allTrails.filter((trail) => indexNotes.includes(trail[0]));
}
let sortedTrails = allTrails
.filter((trail) => trail.length > 0)
Expand Down

0 comments on commit e302a97

Please sign in to comment.