From 9cac7c058108408684332f530d05621fc89401b9 Mon Sep 17 00:00:00 2001 From: Hajime Nagisa <43955981+hajime-nagisa@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:32:25 +0900 Subject: [PATCH] Fix: issue#190 (#317) * Fixed search results with diacritics - Caches are now stored with diacritics regardless of settings.ignoreDiacritics - Modified getMatches() behavior to return results with correct form - Modified ResultItemVault.svelte * Fixed highlighting words with comma and period - remove commas and periods from matches * Fixed highlighting of Cyrillic characters - changed highlight regexp determination to be based on character type * Fixed highlighting problem of Japanese and Korean - marked some Japanese diacritics to escape removal - added NFC normalization to keep right form of Korean character * Fixed highlighting of words with punctuation - deleted space/punctuation list from stringsToRegex() - it seems to be working correctly with words with punctuation and hyphenated words AFAIK * Deleted some unused imports * Modified the comment * Added comment * Fixed highlighting issue with comma and period * Fixed highlighting issue with caret and other symbols - Added `^` to separators - Changed regex to use separators - Added escape of `^` from diacritics removal --- src/cache-manager.ts | 4 +-- src/components/ResultItemVault.svelte | 13 ++++---- src/globals.ts | 7 ++-- src/tools/text-processing.ts | 48 +++++++++++++-------------- src/tools/utils.ts | 11 +++++- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/cache-manager.ts b/src/cache-manager.ts index 06f79fd..f778525 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -17,7 +17,6 @@ import { isFilenameIndexable, logDebug, makeMD5, - removeDiacritics, } from './tools/utils' import type { CanvasData } from 'obsidian/canvas' import type { AsPlainObject } from 'minisearch' @@ -115,7 +114,6 @@ async function getAndMapIndexedDocument( console.warn(`Omnisearch: ${content} content for file`, file.path) content = '' } - content = removeDiacritics(content) const metadata = app.metadataCache.getFileCache(file) // Look for links that lead to non-existing files, @@ -143,7 +141,7 @@ async function getAndMapIndexedDocument( const tags = getTagsFromMetadata(metadata) return { - basename: removeDiacritics(file.basename), + basename: file.basename, content, path: file.path, mtime: file.stat.mtime, diff --git a/src/components/ResultItemVault.svelte b/src/components/ResultItemVault.svelte index ba0dbf6..a0dc7fa 100644 --- a/src/components/ResultItemVault.svelte +++ b/src/components/ResultItemVault.svelte @@ -1,5 +1,5 @@