#87 - create in a new pane + fixed some settings stuff

This commit is contained in:
Simon Cambier
2022-09-10 23:01:25 +02:00
parent 3a0b3cbc3a
commit beaa8e5656
6 changed files with 52 additions and 29 deletions

View File

@@ -18,7 +18,7 @@ import {
wait,
} from './utils'
import type { Query } from './query'
import { settings } from './settings'
import { settings as storeSettings } from './settings'
import {
removeNoteFromCache,
getNoteFromCache,
@@ -31,10 +31,13 @@ import {
saveNotesCacheToFile,
isCacheOutdated,
} from './notes'
import { get } from 'svelte/store'
let minisearchInstance: MiniSearch<IndexedNote>
let isIndexChanged: boolean
const settings = get(storeSettings)
const tokenize = (text: string): string[] => {
const tokens = text.split(SPACE_OR_PUNCTUATION)
const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
@@ -140,6 +143,7 @@ export async function initGlobalSearchIndex(): Promise<void> {
*/
async function search(query: Query): Promise<SearchResult[]> {
if (!query.segmentsToStr()) return []
let results = minisearchInstance.search(query.segmentsToStr(), {
prefix: true,
fuzzy: term => (term.length > 4 ? 0.2 : false),