#53 - Fixed some highlighting issues
This commit is contained in:
@@ -22,7 +22,10 @@ export function resetNotesCache(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadNotesCache(): Promise<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 {
|
try {
|
||||||
const json = await app.vault.adapter.read(notesCacheFilePath)
|
const json = await app.vault.adapter.read(notesCacheFilePath)
|
||||||
notesCache = JSON.parse(json)
|
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'
|
import { parseQuery } from './vendor/parse-query'
|
||||||
|
|
||||||
type QueryToken = {
|
type QueryToken = {
|
||||||
@@ -21,6 +22,7 @@ export class Query {
|
|||||||
public exclusions: QueryToken[] = []
|
public exclusions: QueryToken[] = []
|
||||||
|
|
||||||
constructor(text = '') {
|
constructor(text = '') {
|
||||||
|
if (settings.ignoreDiacritics) text = removeDiacritics(text)
|
||||||
const tokens = parseQuery(text.toLowerCase(), { tokenize: true })
|
const tokens = parseQuery(text.toLowerCase(), { tokenize: true })
|
||||||
this.exclusions = tokens.exclude.text
|
this.exclusions = tokens.exclude.text
|
||||||
.map(this.formatToken)
|
.map(this.formatToken)
|
||||||
@@ -48,5 +50,3 @@ export class Query {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
getNonExistingNotesFromCache,
|
getNonExistingNotesFromCache,
|
||||||
loadNotesCache,
|
loadNotesCache,
|
||||||
saveNotesCacheToFile,
|
saveNotesCacheToFile,
|
||||||
isCacheOutdated
|
isCacheOutdated,
|
||||||
} from './notes'
|
} from './notes'
|
||||||
|
|
||||||
let minisearchInstance: MiniSearch<IndexedNote>
|
let minisearchInstance: MiniSearch<IndexedNote>
|
||||||
@@ -53,7 +53,7 @@ const tokenize = (text: string): string[] => {
|
|||||||
export async function initGlobalSearchIndex(): Promise<void> {
|
export async function initGlobalSearchIndex(): Promise<void> {
|
||||||
const options = {
|
const options = {
|
||||||
tokenize,
|
tokenize,
|
||||||
processTerm: term =>
|
processTerm: (term: string) =>
|
||||||
settings.ignoreDiacritics ? removeDiacritics(term) : term,
|
settings.ignoreDiacritics ? removeDiacritics(term) : term,
|
||||||
idField: 'path',
|
idField: 'path',
|
||||||
fields: [
|
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 {
|
try {
|
||||||
const json = await app.vault.adapter.read(searchIndexFilePath)
|
const json = await app.vault.adapter.read(searchIndexFilePath)
|
||||||
minisearchInstance = MiniSearch.loadJSON(json, options)
|
minisearchInstance = MiniSearch.loadJSON(json, options)
|
||||||
@@ -94,7 +97,8 @@ export async function initGlobalSearchIndex(): Promise<void> {
|
|||||||
if (settings.storeIndexInFile) {
|
if (settings.storeIndexInFile) {
|
||||||
files = allFiles.filter(file => isCacheOutdated(file))
|
files = allFiles.filter(file => isCacheOutdated(file))
|
||||||
notesSuffix = 'modified notes'
|
notesSuffix = 'modified notes'
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
files = allFiles
|
files = allFiles
|
||||||
notesSuffix = 'notes'
|
notesSuffix = 'notes'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,17 +71,17 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Ignore diacritics
|
// Ignore diacritics
|
||||||
// new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
// .setName('Ignore diacritics')
|
.setName('Ignore diacritics')
|
||||||
// .setDesc(
|
.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.',
|
'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 =>
|
.addToggle(toggle =>
|
||||||
// toggle.setValue(settings.ignoreDiacritics).onChange(async v => {
|
toggle.setValue(settings.ignoreDiacritics).onChange(async v => {
|
||||||
// settings.ignoreDiacritics = v
|
settings.ignoreDiacritics = v
|
||||||
// await saveSettings(this.plugin)
|
await saveSettings(this.plugin)
|
||||||
// }),
|
}),
|
||||||
// )
|
)
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Store index in file')
|
.setName('Store index in file')
|
||||||
@@ -194,7 +194,7 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
||||||
respectExcluded: true,
|
respectExcluded: true,
|
||||||
reindexInRealTime: false,
|
reindexInRealTime: false,
|
||||||
ignoreDiacritics: true,
|
ignoreDiacritics: false,
|
||||||
|
|
||||||
showIndexingNotices: false,
|
showIndexingNotices: false,
|
||||||
showShortName: false,
|
showShortName: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user