#115 - Added a setting to re-execute the previous query when opening Omnisearch

This commit is contained in:
Simon Cambier
2022-10-24 07:01:25 +02:00
parent 6af0ad9178
commit 6d73d8fa7c
2 changed files with 20 additions and 2 deletions

View File

@@ -42,7 +42,9 @@
eventBus.on('vault', 'prev-search-history', prevSearchHistory)
eventBus.on('vault', 'next-search-history', nextSearchHistory)
await NotesIndex.refreshIndex()
previousQuery = (await cacheManager.getSearchHistory())[0]
if (settings.showPreviousQueryResults) {
previousQuery = (await cacheManager.getSearchHistory())[0]
}
})
onDestroy(() => {

View File

@@ -38,6 +38,8 @@ export interface OmnisearchSettings extends WeightingSettings {
showExcerpt: boolean
/** Enable a "create note" button in the Vault Search modal */
showCreateButton: boolean
/** Re-execute the last query when opening Omnisearch */
showPreviousQueryResults: boolean
/** Vim mode shortcuts */
CtrlJK: boolean
/** Vim mode shortcuts */
@@ -214,7 +216,7 @@ export class SettingsTab extends PluginSettingTab {
})
)
// Show Context
// Show context excerpt
new Setting(containerEl)
.setName('Show excerpt')
.setDesc(
@@ -226,6 +228,19 @@ export class SettingsTab extends PluginSettingTab {
})
)
// Show context excerpt
new Setting(containerEl)
.setName('Show previous query results')
.setDesc(
'Re-executes the previous query when opening Omnisearch'
)
.addToggle(toggle =>
toggle.setValue(settings.showPreviousQueryResults).onChange(async v => {
settings.showPreviousQueryResults = v
await saveSettings(this.plugin)
})
)
// Show "Create note" button
const createBtnDesc = new DocumentFragment()
createBtnDesc.createSpan({}, span => {
@@ -352,6 +367,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
ribbonIcon: true,
showExcerpt: true,
showCreateButton: false,
showPreviousQueryResults: true,
weightBasename: 2,
weightH1: 1.5,