From c8bdcad17c5979b49b659738711e1d73d021086d Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 31 Dec 2022 21:26:15 +0100 Subject: [PATCH] Small (potential) bugfixes --- src/components/ModalVault.svelte | 2 ++ src/globals.ts | 8 +------- src/main.ts | 4 +++- src/tools/utils.ts | 3 +++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/ModalVault.svelte b/src/components/ModalVault.svelte index c92bd25..dee76be 100644 --- a/src/components/ModalVault.svelte +++ b/src/components/ModalVault.svelte @@ -31,6 +31,8 @@ searching = true updateResults().then(() => { searching = false + }).catch((e) => { + console.error(e) }) } else { searching = false diff --git a/src/globals.ts b/src/globals.ts index e24a7a5..7bdc5d1 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -87,13 +87,7 @@ export function getChsSegmenter(): any | undefined { } export type TextExtractorApi = { - extractText: ( - file: TFile, - ocrOptions?: { - langs: string[] - } - ) => Promise - getOcrLangs: () => string[] + extractText: (file: TFile) => Promise canFileBeExtracted: (filePath: string) => boolean } diff --git a/src/main.ts b/src/main.ts index 85269b9..d77ce59 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,7 +46,9 @@ export default class OmnisearchPlugin extends Plugin { id: 'show-modal-infile', name: 'In-file search', editorCallback: (_editor, view) => { - new OmnisearchInFileModal(app, view.file).open() + if (view.file) { + new OmnisearchInFileModal(app, view.file).open() + } }, }) diff --git a/src/tools/utils.ts b/src/tools/utils.ts index 51ad737..6137d10 100644 --- a/src/tools/utils.ts +++ b/src/tools/utils.ts @@ -202,6 +202,9 @@ export function getTagsFromMetadata(metadata: CachedMetadata | null): string[] { * https://stackoverflow.com/a/37511463 */ export function removeDiacritics(str: string): string { + if (str === null || str === undefined) { + return '' + } return str.normalize('NFD').replace(/\p{Diacritic}/gu, '') }