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
This commit is contained in:
Hajime Nagisa
2023-11-29 15:32:25 +09:00
committed by GitHub
parent 115886af78
commit 9cac7c0581
5 changed files with 44 additions and 39 deletions

View File

@@ -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,