diff --git a/JsSnippets.md b/JsSnippets.md index 7608eda..e42f3da 100644 --- a/JsSnippets.md +++ b/JsSnippets.md @@ -39,7 +39,7 @@ function regexLastIndexOf(string, regex, startpos) { function jumpHeading(isForward) { const editor = view.editor; let posToSearchFrom = editor.getCursor(); - posToSearchFrom.line += isForward ? 0 : -1; + posToSearchFrom.line += isForward ? 1 : -1; const cursorOffset = editor.posToOffset(posToSearchFrom); const lookupToUse = isForward ? regexIndexOf : regexLastIndexOf; let headingOffset = lookupToUse(editor.getValue(), /^#(#*) /gm, cursorOffset); @@ -72,7 +72,7 @@ Append this function to the file mentioned above (after jumpHeading). function jumpNextLink(isForward) { const editor = view.editor; let posToSearchFrom = editor.getCursor(); - posToSearchFrom.line += isForward ? 1 : -1; + posToSearchFrom.line += isForward ? 0 : -1; const cursorOffset = editor.posToOffset(posToSearchFrom); const lookupToUse = isForward ? regexIndexOf : regexLastIndexOf; let headingOffset = lookupToUse(editor.getValue(), /\[\[/g, cursorOffset);