diff --git a/src/Components/TrailPath.svelte b/src/Components/TrailPath.svelte index 013f818d..e92f675b 100644 --- a/src/Components/TrailPath.svelte +++ b/src/Components/TrailPath.svelte @@ -3,7 +3,7 @@ hoverPreview, openOrSwitch, } from "obsidian-community-lib/dist/utils"; - import { TRAIL_LENGTHS } from "../constants"; + import { getTrailLength } from "../Views/TrailView"; import type BCPlugin from "../main"; import { dropDendron } from "../Utils/generalUtils"; import { getAlt } from "../Utils/ObsidianUtils"; @@ -15,12 +15,6 @@ const { view } = app.workspace.activeLeaf; let { showAll, noPathMessage, trailSeperator } = settings; - function getTrailLength(curr: string, offset: number = 1) { - return TRAIL_LENGTHS[ - (TRAIL_LENGTHS.indexOf(curr) + offset) % TRAIL_LENGTHS.length - ]; - } - let trail_length = showAll; $: trailsToShow = diff --git a/src/Views/TrailView.ts b/src/Views/TrailView.ts index 2126ae0c..510888a9 100644 --- a/src/Views/TrailView.ts +++ b/src/Views/TrailView.ts @@ -8,6 +8,7 @@ import { BC_HIDE_TRAIL, blankRealNImplied, JUGGL_TRAIL_DEFAULTS, + TRAIL_LENGTHS, } from "../constants"; import type { BCSettings, EdgeAttr, RealNImplied } from "../interfaces"; import type BCPlugin from "../main"; @@ -96,6 +97,12 @@ function getNextNPrev(plugin: BCPlugin, currNode: string) { return nextNPrev; } +export function getTrailLength(curr: string, offset: number = 1) { + const index = + (TRAIL_LENGTHS.indexOf(curr) + offset) % TRAIL_LENGTHS.length; + return TRAIL_LENGTHS[index < 0 ? TRAIL_LENGTHS.length + index : index]; +} + export async function drawTrail(plugin: BCPlugin): Promise { try { const { settings, db, app, mainG } = plugin;