From f67d9d1a251b469e02343b0a20e93a2b3b1ea59d Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sun, 27 Nov 2022 16:35:28 +0100 Subject: [PATCH] Fixed file watching --- src/main.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 32301a4..c62e756 100644 --- a/src/main.ts +++ b/src/main.ts @@ -54,8 +54,10 @@ export default class OmnisearchPlugin extends Plugin { // Listeners to keep the search index up-to-date this.registerEvent( this.app.vault.on('create', async file => { - cacheManager.addToLiveCache(file.path) - searchEngine.addFromPaths([file.path], false) + if (isFileIndexable(file.path)) { + await cacheManager.addToLiveCache(file.path) + searchEngine.addFromPaths([file.path], false) + } }) ) this.registerEvent( @@ -66,13 +68,15 @@ export default class OmnisearchPlugin extends Plugin { ) this.registerEvent( this.app.vault.on('modify', async file => { - cacheManager.addToLiveCache(file.path) - NotesIndex.markNoteForReindex(file) + if (isFileIndexable(file.path)) { + await cacheManager.addToLiveCache(file.path) + NotesIndex.markNoteForReindex(file) + } }) ) this.registerEvent( this.app.vault.on('rename', async (file, oldPath) => { - if (file instanceof TFile && isFilePlaintext(file.path)) { + if (isFileIndexable(file.path)) { cacheManager.removeFromLiveCache(oldPath) cacheManager.addToLiveCache(file.path) searchEngine.removeFromPaths([oldPath])