Minisearch 6.0 mostly ok
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
import { loopIndex } from 'src/tools/utils'
|
||||
import { onDestroy, onMount, tick } from 'svelte'
|
||||
import { MarkdownView } from 'obsidian'
|
||||
import { SearchEngine } from 'src/search/search-engine'
|
||||
import ModalContainer from './ModalContainer.svelte'
|
||||
import {
|
||||
OmnisearchInFileModal,
|
||||
@@ -18,6 +17,7 @@
|
||||
import ResultItemInFile from './ResultItemInFile.svelte'
|
||||
import { Query } from 'src/search/query'
|
||||
import { openNote } from 'src/tools/notes'
|
||||
import { searchEngine } from 'src/search/omnisearch'
|
||||
|
||||
export let modal: OmnisearchInFileModal
|
||||
export let parent: OmnisearchVaultModal | null = null
|
||||
@@ -50,7 +50,7 @@
|
||||
query = new Query(searchQuery)
|
||||
note =
|
||||
(
|
||||
await SearchEngine.getEngine().getSuggestions(query, {
|
||||
await searchEngine.getSuggestions(query, {
|
||||
singleFilePath,
|
||||
})
|
||||
)[0] ?? null
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
import { onDestroy, onMount, tick } from 'svelte'
|
||||
import InputSearch from './InputSearch.svelte'
|
||||
import ModalContainer from './ModalContainer.svelte'
|
||||
import { eventBus, IndexingStep, type ResultNote } from 'src/globals'
|
||||
import { eventBus, indexingStep, IndexingStepType, type ResultNote } from 'src/globals'
|
||||
import { createNote, openNote } from 'src/tools/notes'
|
||||
import { SearchEngine } from 'src/search/search-engine'
|
||||
import { getCtrlKeyLabel, getExtension, isFilePDF, loopIndex } from 'src/tools/utils'
|
||||
import {
|
||||
OmnisearchInFileModal,
|
||||
@@ -16,6 +15,7 @@
|
||||
import { settings } from '../settings'
|
||||
import * as NotesIndex from '../notes-index'
|
||||
import { cacheManager } from '../cache-manager'
|
||||
import { searchEngine } from 'src/search/omnisearch'
|
||||
|
||||
export let modal: OmnisearchVaultModal
|
||||
export let previousQuery: string | undefined
|
||||
@@ -24,7 +24,6 @@
|
||||
let searchQuery: string | undefined
|
||||
let resultNotes: ResultNote[] = []
|
||||
let query: Query
|
||||
let { indexingStep } = SearchEngine
|
||||
let indexingStepDesc = ''
|
||||
|
||||
$: selectedNote = resultNotes[selectedIndex]
|
||||
@@ -36,20 +35,20 @@
|
||||
}
|
||||
$: {
|
||||
switch ($indexingStep) {
|
||||
case IndexingStep.LoadingCache:
|
||||
case IndexingStepType.LoadingCache:
|
||||
indexingStepDesc = 'Loading cache...'
|
||||
break
|
||||
case IndexingStep.ReadingNotes:
|
||||
case IndexingStepType.ReadingNotes:
|
||||
updateResults()
|
||||
indexingStepDesc = 'Reading notes...'
|
||||
break
|
||||
case IndexingStep.ReadingPDFs:
|
||||
case IndexingStepType.ReadingPDFs:
|
||||
indexingStepDesc = 'Reading PDFs...'
|
||||
break
|
||||
case IndexingStep.ReadingImages:
|
||||
case IndexingStepType.ReadingImages:
|
||||
indexingStepDesc = 'Reading images...'
|
||||
break
|
||||
case IndexingStep.UpdatingCache:
|
||||
case IndexingStepType.UpdatingCache:
|
||||
indexingStepDesc = 'Updating cache...'
|
||||
break
|
||||
default:
|
||||
@@ -99,7 +98,7 @@
|
||||
|
||||
async function updateResults() {
|
||||
query = new Query(searchQuery)
|
||||
resultNotes = (await SearchEngine.getEngine().getSuggestions(query)).sort(
|
||||
resultNotes = (await searchEngine.getSuggestions(query)).sort(
|
||||
(a, b) => b.score - a.score
|
||||
)
|
||||
selectedIndex = 0
|
||||
@@ -139,7 +138,7 @@
|
||||
openNote(note, newPane)
|
||||
}
|
||||
|
||||
async function onClickCreateNote(e: MouseEvent) {
|
||||
async function onClickCreateNote(_e: MouseEvent) {
|
||||
await createNoteAndCloseModal()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { cacheManager } from 'src/cache-manager'
|
||||
import { settings, showExcerpt } from 'src/settings'
|
||||
import type { ResultNote } from '../globals'
|
||||
import {
|
||||
@@ -28,7 +27,7 @@
|
||||
}
|
||||
$: reg = stringsToRegex(note.foundWords)
|
||||
$: cleanedContent = makeExcerpt(note.content, note.matches[0]?.offset ?? -1)
|
||||
$: glyph = cacheManager.getLiveDocument(note.path)?.doesNotExist
|
||||
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
|
||||
$: title = settings.showShortName ? note.basename : note.path
|
||||
</script>
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ abstract class OmnisearchModal extends Modal {
|
||||
{ k: 'K', dir: 'up' },
|
||||
] as const) {
|
||||
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||
this.scope.register([modifier], key.k, e => {
|
||||
this.scope.register([modifier], key.k, _e => {
|
||||
if (this.app.vault.getConfig('vimMode')) {
|
||||
// e.preventDefault()
|
||||
eventBus.emit('arrow-' + key.dir)
|
||||
@@ -50,7 +50,7 @@ abstract class OmnisearchModal extends Modal {
|
||||
{ k: 'P', dir: 'up' },
|
||||
] as const) {
|
||||
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||
this.scope.register([modifier], key.k, e => {
|
||||
this.scope.register([modifier], key.k, _e => {
|
||||
if (this.app.vault.getConfig('vimMode')) {
|
||||
// e.preventDefault()
|
||||
eventBus.emit('arrow-' + key.dir)
|
||||
@@ -108,7 +108,7 @@ abstract class OmnisearchModal extends Modal {
|
||||
})
|
||||
|
||||
// Context
|
||||
this.scope.register(['Ctrl'], 'H', e => {
|
||||
this.scope.register(['Ctrl'], 'H', _e => {
|
||||
eventBus.emit(EventNames.ToggleExcerpts)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user