From d94d90f64b3c5ff6bfb392e5340570a6c2c2530e Mon Sep 17 00:00:00 2001 From: jaanonim Date: Sun, 1 Sep 2024 15:58:34 +0200 Subject: [PATCH] fix errors --- src/EditorSuggester.ts | 51 +++++++++++++++++++++--------------------- src/GenerateLinks.ts | 10 ++++++--- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/EditorSuggester.ts b/src/EditorSuggester.ts index 908904e..2cecc22 100644 --- a/src/EditorSuggester.ts +++ b/src/EditorSuggester.ts @@ -124,29 +124,30 @@ export function getSuggestionsFromQuery( const verseEndNumber = numbers.length === 3 ? parseInt(numbers[2]) : undefined; - return booksUrl - .flatMap((bookUrl) => - settings.bibleVersions.map((version) => { - if (isLink) { - return new VerseLink( - version, - bookUrl, - bookName, - chapterNumber, - verseNumber, - verseEndNumber - ); - } else if (verseNumber !== undefined) { - return new VerseEmbed( - version, - bookUrl, - bookName, - chapterNumber, - verseNumber, - verseEndNumber - ); - } - }) - ) - .filter((v) => v !== undefined); + return booksUrl.flatMap( + (bookUrl) => + settings.bibleVersions + .map((version) => { + if (isLink) { + return new VerseLink( + version, + bookUrl, + bookName, + chapterNumber, + verseNumber, + verseEndNumber + ); + } else if (verseNumber !== undefined) { + return new VerseEmbed( + version, + bookUrl, + bookName, + chapterNumber, + verseNumber, + verseEndNumber + ); + } + }) + .filter((v) => v !== undefined) as Verse[] + ); } diff --git a/src/GenerateLinks.ts b/src/GenerateLinks.ts index 4e0774a..5495d52 100644 --- a/src/GenerateLinks.ts +++ b/src/GenerateLinks.ts @@ -14,11 +14,15 @@ export default function GenerateLinks( const match = [...line.matchAll(linkRegex)]; match.forEach((match) => { - const suggestions = getSuggestionsFromQuery(match[0], settings); - suggestions.forEach((s) => { + const suggestions = getSuggestionsFromQuery( + match[0], + true, + settings + ); + suggestions.forEach(async (s) => { if (match.index === undefined) return; editor.replaceRange( - s.toLink(), + await s.toReplace(), { line: i, ch: match.index,