From 5ced77af5e26090b024c8a3a75484500d2cf5d24 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Mon, 11 Apr 2022 10:41:06 +0200 Subject: [PATCH] Fixed multi-terms search --- manifest.json | 2 +- package.json | 2 +- src/main.ts | 2 +- versions.json | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 3636f6a..27d2926 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "scambier.obsidian-omnisearch", "name": "Omnisearch", - "version": "0.1.3", + "version": "0.1.4", "minAppVersion": "0.14.2", "description": "Search over organization", "author": "Simon Cambier", diff --git a/package.json b/package.json index 4c1027d..0271c23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scambier.obsidian-search", - "version": "0.1.3", + "version": "0.1.4", "description": "Search over organization", "main": "dist/main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index b00a3e3..9d63375 100644 --- a/src/main.ts +++ b/src/main.ts @@ -239,7 +239,7 @@ class OmnisearchModal extends SuggestModal { // Sort the terms from smaller to larger // and highlight them in the title and body const terms = result.terms.sort((a, b) => a.length - b.length) - const reg = new RegExp(escapeRegex(terms.join('|')), 'gi') + const reg = new RegExp(terms.map(escapeRegex).join('|'), 'gi') body = body.replace(reg, highlighter) title = title.replace(reg, highlighter) name = name.replace(reg, highlighter) diff --git a/versions.json b/versions.json index a105459..f82ad07 100644 --- a/versions.json +++ b/versions.json @@ -2,5 +2,6 @@ "0.1.0": "0.14.2", "0.1.1": "0.14.2", "0.1.2": "0.14.2", - "0.1.3": "0.14.2" + "0.1.3": "0.14.2", + "0.1.4": "0.14.2" } \ No newline at end of file