From 0895ca4d0749877b250efb0f5a3adb0752d89837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Date: Thu, 29 Jun 2023 12:46:35 +0200 Subject: [PATCH] Update JsSnippets.md --- JsSnippets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);