#70 - Correctly toggling and saving settings.showContext

This commit is contained in:
Simon Cambier
2022-09-20 12:53:37 +02:00
parent 31aab49c54
commit 35110f488d
4 changed files with 35 additions and 27 deletions

View File

@@ -16,17 +16,12 @@ export interface OmnisearchSettings extends WeightingSettings {
showIndexingNotices: boolean
ribbonIcon: boolean
showShortName: boolean
showContext: SearchContextType
showContext: boolean
CtrlJK: boolean
CtrlNP: boolean
storeIndexInFile: boolean
}
export enum SearchContextType {
None,
Simple,
}
export class SettingsTab extends PluginSettingTab {
plugin: OmnisearchPlugin
@@ -131,6 +126,25 @@ export class SettingsTab extends PluginSettingTab {
})
)
// Show Context
new Setting(containerEl)
.setName('Show context')
.setDesc(
'Shows the part of the note that matches the search. Disable this to only show filenames in results.'
)
.addToggle(toggle =>
toggle.setValue(get(settings).showContext).onChange(async v => {
settings.update(s => {
s.showContext = v
return s
})
await saveSettings(this.plugin)
if (v) {
this.plugin.addRibbonButton()
}
})
)
// Show notices
new Setting(containerEl)
.setName('Show indexing notices')
@@ -243,7 +257,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
showIndexingNotices: false,
showShortName: false,
ribbonIcon: true,
showContext: SearchContextType.Simple,
showContext: true,
weightBasename: 2,
weightH1: 1.5,