Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanonim committed Sep 1, 2024
1 parent 2e0bfdf commit d94d90f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
51 changes: 26 additions & 25 deletions src/EditorSuggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
);
}
10 changes: 7 additions & 3 deletions src/GenerateLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d94d90f

Please sign in to comment.