Update JsSnippets.md

This commit is contained in:
Maciej Wieczór-Retman 2023-06-29 12:46:35 +02:00 committed by GitHub
parent dd1838a175
commit 0895ca4d07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);