#53 - Fixed some highlighting issues
This commit is contained in:
@@ -22,7 +22,10 @@ export function resetNotesCache(): void {
|
||||
}
|
||||
|
||||
export async function loadNotesCache(): Promise<void> {
|
||||
if (settings.storeIndexInFile && await app.vault.adapter.exists(notesCacheFilePath)) {
|
||||
if (
|
||||
settings.storeIndexInFile &&
|
||||
(await app.vault.adapter.exists(notesCacheFilePath))
|
||||
) {
|
||||
try {
|
||||
const json = await app.vault.adapter.read(notesCacheFilePath)
|
||||
notesCache = JSON.parse(json)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { stripSurroundingQuotes } from './utils'
|
||||
import { settings } from './settings'
|
||||
import { removeDiacritics, stripSurroundingQuotes } from './utils'
|
||||
import { parseQuery } from './vendor/parse-query'
|
||||
|
||||
type QueryToken = {
|
||||
@@ -21,6 +22,7 @@ export class Query {
|
||||
public exclusions: QueryToken[] = []
|
||||
|
||||
constructor(text = '') {
|
||||
if (settings.ignoreDiacritics) text = removeDiacritics(text)
|
||||
const tokens = parseQuery(text.toLowerCase(), { tokenize: true })
|
||||
this.exclusions = tokens.exclude.text
|
||||
.map(this.formatToken)
|
||||
@@ -48,5 +50,3 @@ export class Query {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
getNonExistingNotesFromCache,
|
||||
loadNotesCache,
|
||||
saveNotesCacheToFile,
|
||||
isCacheOutdated
|
||||
isCacheOutdated,
|
||||
} from './notes'
|
||||
|
||||
let minisearchInstance: MiniSearch<IndexedNote>
|
||||
@@ -53,7 +53,7 @@ const tokenize = (text: string): string[] => {
|
||||
export async function initGlobalSearchIndex(): Promise<void> {
|
||||
const options = {
|
||||
tokenize,
|
||||
processTerm: term =>
|
||||
processTerm: (term: string) =>
|
||||
settings.ignoreDiacritics ? removeDiacritics(term) : term,
|
||||
idField: 'path',
|
||||
fields: [
|
||||
@@ -66,7 +66,10 @@ export async function initGlobalSearchIndex(): Promise<void> {
|
||||
],
|
||||
}
|
||||
|
||||
if (settings.storeIndexInFile && await app.vault.adapter.exists(searchIndexFilePath)) {
|
||||
if (
|
||||
settings.storeIndexInFile &&
|
||||
(await app.vault.adapter.exists(searchIndexFilePath))
|
||||
) {
|
||||
try {
|
||||
const json = await app.vault.adapter.read(searchIndexFilePath)
|
||||
minisearchInstance = MiniSearch.loadJSON(json, options)
|
||||
@@ -94,7 +97,8 @@ export async function initGlobalSearchIndex(): Promise<void> {
|
||||
if (settings.storeIndexInFile) {
|
||||
files = allFiles.filter(file => isCacheOutdated(file))
|
||||
notesSuffix = 'modified notes'
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
files = allFiles
|
||||
notesSuffix = 'notes'
|
||||
}
|
||||
|
||||
@@ -71,17 +71,17 @@ export class SettingsTab extends PluginSettingTab {
|
||||
)
|
||||
|
||||
// Ignore diacritics
|
||||
// new Setting(containerEl)
|
||||
// .setName('Ignore diacritics')
|
||||
// .setDesc(
|
||||
// 'Normalize diacritics in search terms. Words like "brûlée" or "žluťoučký" will be indexed as "brulee" and "zlutoucky". Needs a restart to take effect.',
|
||||
// )
|
||||
// .addToggle(toggle =>
|
||||
// toggle.setValue(settings.ignoreDiacritics).onChange(async v => {
|
||||
// settings.ignoreDiacritics = v
|
||||
// await saveSettings(this.plugin)
|
||||
// }),
|
||||
// )
|
||||
new Setting(containerEl)
|
||||
.setName('Ignore diacritics')
|
||||
.setDesc(
|
||||
'EXPERIMENTAL - Normalize diacritics in search terms. Words like "brûlée" or "žluťoučký" will be indexed as "brulee" and "zlutoucky". Needs a restart to take effect.',
|
||||
)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.ignoreDiacritics).onChange(async v => {
|
||||
settings.ignoreDiacritics = v
|
||||
await saveSettings(this.plugin)
|
||||
}),
|
||||
)
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Store index in file')
|
||||
@@ -194,7 +194,7 @@ export class SettingsTab extends PluginSettingTab {
|
||||
export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
||||
respectExcluded: true,
|
||||
reindexInRealTime: false,
|
||||
ignoreDiacritics: true,
|
||||
ignoreDiacritics: false,
|
||||
|
||||
showIndexingNotices: false,
|
||||
showShortName: false,
|
||||
|
||||
Reference in New Issue
Block a user