From ce2d1fa5f4cd051e78469a16157e7682949553f1 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 12 Nov 2022 16:26:02 +0100 Subject: [PATCH] Workaround for #129 --- src/cache-manager.ts | 1 - src/file-loader.ts | 1 + src/notes-index.ts | 1 - src/search/search-engine.ts | 6 +++++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cache-manager.ts b/src/cache-manager.ts index b287d68..a71eac1 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -4,7 +4,6 @@ import { database } from './database' import MiniSearch from 'minisearch' import { minisearchOptions } from './search/search-engine' import { makeMD5 } from './tools/utils' -import { settings } from './settings' class CacheManager { private liveDocuments: Map = new Map() diff --git a/src/file-loader.ts b/src/file-loader.ts index 1bec451..f8cb0f3 100644 --- a/src/file-loader.ts +++ b/src/file-loader.ts @@ -84,6 +84,7 @@ export async function fileToIndexedDocument( // Look for links that lead to non-existing files, // and add them to the index. if (metadata) { + // FIXME: https://github.com/scambier/obsidian-omnisearch/issues/129 const nonExisting = getNonExistingNotes(file, metadata) for (const name of nonExisting.filter( o => !cacheManager.getLiveDocument(o) diff --git a/src/notes-index.ts b/src/notes-index.ts index f4e3e8d..4b022f8 100644 --- a/src/notes-index.ts +++ b/src/notes-index.ts @@ -1,7 +1,6 @@ import { Notice, TAbstractFile, TFile } from 'obsidian' import { isFileIndexable, wait } from './tools/utils' import { removeAnchors } from './tools/notes' -import { settings } from './settings' import { SearchEngine } from './search/search-engine' import { cacheManager } from './cache-manager' import type { IndexedDocument } from './globals' diff --git a/src/search/search-engine.ts b/src/search/search-engine.ts index ea46881..04e967a 100644 --- a/src/search/search-engine.ts +++ b/src/search/search-engine.ts @@ -150,7 +150,11 @@ export class SearchEngine { return exclusions.every(q => !content.includes(q.value)) }) } - return results + // FIXME: + // Dedupe results - clutch for https://github.com/scambier/obsidian-omnisearch/issues/129 + return results.filter( + (result, index, arr) => arr.findIndex(t => t.id === result.id) === index + ) } /**