Skip to content

Commit

Permalink
make it work again
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hub committed Dec 13, 2024
1 parent 2ef6ad0 commit 5bfb369
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/suggesetor/VerseEditorSuggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ export class VerseEditorSuggester extends EditorSuggest<VerseSuggesting> {
const { bookVerseQuery, translationQuery } = this.getBookVerseAndTranslation(queryContent)

const verseMatchResult = verseMatch(bookVerseQuery)
const versionSelectionMatchResult = versionSelectionMatch(translationQuery)

if (verseMatchResult && verseMatchResult.length > 0) {
const versionSelectionMatchResult = versionSelectionMatch(translationQuery)
if (!translationQuery || !versionSelectionMatchResult || getBibleVersion(versionSelectionMatchResult).key == versionSelectionMatchResult ) {
if (versionSelectionMatchResult && getBibleVersion(versionSelectionMatchResult).key == versionSelectionMatchResult ) {
console.log(`set version : ${versionSelectionMatchResult}`)
this.plugin.settings.bibleVersion = versionSelectionMatchResult // pick a version
this.plugin.saveSettings() //todo this is an async function, so it may not be saved before the getSuggestions is called
} else {
// revert back to default version
if (this.settings.bibleVersion != this.settings.defaultBibleVersion) {
this.settings.bibleVersion = this.settings.defaultBibleVersion // reset to default
console.log(`defaultBibleVersion : ${this.settings.defaultBibleVersion}`)
this.plugin.saveSettings()
}
} else {
console.log(`set version : ${versionSelectionMatchResult}`)
this.plugin.settings.bibleVersion = versionSelectionMatchResult // pick a version
this.plugin.saveSettings() //todo this is an async function, so it may not be saved before the getSuggestions is called
}

console.debug('trigger on', queryContent)
Expand All @@ -94,7 +96,7 @@ export class VerseEditorSuggester extends EditorSuggest<VerseSuggesting> {
line: cursor.line,
ch: queryContent.lastIndexOf(verseMatchResult),
},
query: queryContent,
query: `${verseMatchResult}@${versionSelectionMatchResult}`,
}
}
return null
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getSuggestionsFromQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getSuggestionsFromQuery = async (
settings: BibleReferencePluginSettings,
translation?: string
): Promise<VerseSuggesting[]> => {
console.debug('get suggestion for query ', queryWithoutPrefix.toLowerCase())
console.debug('get suggestion for query ', queryWithoutPrefix.toLowerCase(), translation, settings.bibleVersion, settings.defaultBibleVersion)

const bookNameMatchingResults = queryWithoutPrefix.match(BOOK_REG)
const rawBookName = bookNameMatchingResults?.length
Expand Down

0 comments on commit 5bfb369

Please sign in to comment.