Skip to content

Commit

Permalink
fix(Path View): 🐛 Trail_Length: Modulo wasn't wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Apr 29, 2022
1 parent d58fd33 commit 6d88364
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/Components/TrailPath.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 =
Expand Down
7 changes: 7 additions & 0 deletions src/Views/TrailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<void> {
try {
const { settings, db, app, mainG } = plugin;
Expand Down

0 comments on commit 6d88364

Please sign in to comment.