Skip to content

Commit

Permalink
fix querying multiple verse
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedictteo05 committed Dec 8, 2024
1 parent 430a6fb commit 5049931
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/suggesetor/VerseEditorSuggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ export class VerseEditorSuggester extends EditorSuggest<VerseSuggesting> {
const queryContent = currentContent.substring(2)

const match = verseMatch(queryContent)

if (match) {

const vMatch = versionMatch(queryContent)
if (vMatch) {
this.plugin.settings.bibleVersion = vMatch
if (getBibleVersion(vMatch).key == vMatch) {
this.plugin.settings.bibleVersion = vMatch
this.plugin.saveSettings()
}
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/reg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('test modal reg matching in different languages', () => {
})

test('should match version with only alphabets', () => {
const modal = '-niv2011'
const modal = '-esv'
const reg = new RegExp(VERSION_REG)
expect(reg.test(modal)).toBe(true)
})
Expand All @@ -87,10 +87,10 @@ describe('test modal reg matching in different languages', () => {
expect(reg.test(modal)).toBe(true)
})

test('should not match when there is hyphen', () => {
const modal = '-should-fail'
const reg = new RegExp(MODAL_REG)
expect(reg.test(modal)).toBe(false)
test('should match even when there is hyphen', () => {
const modal = '-oeb-cw'
const reg = new RegExp(VERSION_REG)
expect(reg.test(modal)).toBe(true)
})

})
2 changes: 1 addition & 1 deletion src/utils/regs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const MODAL_REG = /([123])*\s*([\p{L}[\\\]^_`a-zA-Z]{2,100}|\p{Script=Han

export const BOOK_REG = /([123])*\s*([\p{L}[\\\]^_`a-zA-Z]{2,100}|\p{Script=Han}{1,})/isu

export const VERSION_REG = /(-[a-zA-Z0-9]+)$/isu
export const VERSION_REG = /-[a-zA-Z][a-zA-Z0-9-]*$/isu

// export const BOOK_REG = /[123]*\s*[A-Z\[\\\]^_`a-z]{2,}/

Expand Down

0 comments on commit 5049931

Please sign in to comment.